model
Based on Elixir, which in turn is based on SQLAlchemy thus requiring Elixir to be installed. If Elixir or SQLAlchemy is not installed, importing this module will raise an ImportError.
This module inherits & exports all members of elixir and exports sqlalchemy as sql.
Practical use
Let's look at one of the example applications; kittens_orm, which exemplifies the basics of CRUD:
from smisk.mvc.model import *
class Kitten(Entity):
name = Field(Unicode(64))
color = Field(Unicode(32))
Once the server is running, you can create kittens via HTTP:
http://localhost:8080/create?name=Busta+Rhymes&color=red
See also:
- http://elixir.ematia.de/trac/wiki/TutorialDivingIn
- http://www.sqlalchemy.org/docs/05/ormtutorial.html
Configuration parameters
smisk.mvc.model.urlSQLAlchemy database URL string, e.g.
sqlite:///myapp.dborpostgresql://user:pass@host/db. See SQLAlchemy create_engine().smisk.mvc.model.pool_sizeNumber of connections to keep open inside the connection pool. See http://www.sqlalchemy.org/docs/05/dbengine.html#dbengine_options.
smisk.mvc.model.max_overflowWhen the number of checked-out connections reaches
pool_size, additional connections will be returned up to this limit. Set to-1for no overflow limit. See http://elixir.ematia.de/apidocs/elixir.options.html.smisk.mvc.model.optionsDefault options for the SQLAlchemy create_engine() call.
Attributes
smisk.mvc.model.sqlThe
sqlalchemymodule, re-exported for convenience.
Functions
smisk.mvc.model.setup()Configure Elixir metadata and create tables. This function is automatically called by
smisk.mvc.Application.service().smisk.mvc.model.session_remove()Remove the current SQLAlchemy session. Called automatically at the end of each request by
smisk.mvc.Application.service().
Classes
- class
smisk.mvc.model.Entity Base class for all ORM model entities. Re-exported from
elixir.