S
smisk

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:

Configuration parameters

smisk.mvc.model.url

SQLAlchemy database URL string, e.g. sqlite:///myapp.db or postgresql://user:pass@host/db. See SQLAlchemy create_engine().

smisk.mvc.model.pool_size

Number of connections to keep open inside the connection pool. See http://www.sqlalchemy.org/docs/05/dbengine.html#dbengine_options.

smisk.mvc.model.max_overflow

When the number of checked-out connections reaches pool_size, additional connections will be returned up to this limit. Set to -1 for no overflow limit. See http://elixir.ematia.de/apidocs/elixir.options.html.

smisk.mvc.model.options

Default options for the SQLAlchemy create_engine() call.

Attributes

smisk.mvc.model.sql

The sqlalchemy module, 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.