Documentation

Entity

Entity is the base class for all entities, all entities inherit this class. A couple of options can be specified by defining a nested class named "turboentity" like this:

class MyEntity (Entity):
     class turboentity:
        option1_name = value1
        option2_name = value2
        ...

Possible options are:

use_shortnames

By default the name of the table of the entity's database representation is the full module path, with dots replaced by underscores, appended by a single underscore, appended by the classname.

Example:

The table's name for the entity myproject.model.Customer will be "myproject_model_Customer".

If you set use_shortnames to True, the tablename will just be the name of the entity, in the example above this would be just "Customer".

tablename

By setting the option tablename you can define a custom tablename instead. use_shortnames will be ignored in that case.

metadata

Specifies a custom metadata-object for this entity.

top

Column

Stores column specification.

Parameters are:

coltype

The column's type, any type from sqlalchemy.types, custom column types work as well, of course. This parameter is mandatory.

primary_key

If set to True, this column will be a primary key.

polymorphic_column

If set to True, this column will store the concrete type (module.ClassName) of the stored entity, when using polymorphic inheritance.

Any other parameters (eg. cascade, private, index, post_update, ...) will simply be passed through to SQLAlchemy's Column() function, if specified.

top

Relationship: OneToOne, OneToMany, ManyToOne and ManyToMany

Baseclass for all types of relationships.

Never instantiate this class directly! Always use the appropriate subclass - ie. one of:

The parameters to the constructors of those classes are basically the same for all four types of relationships:

target

Name of the target entity, either the class name (if source and target share the same module) or the full path in the form "module.ClassName" (as string).

backref

The column name of the inverse, this is optional if you also define the other end of the relationship on the target-entity.

colname

Name of the property, this is optional.

order_by

How the target list should be ordered, optional (only applies to OneToMany, ManyToMany) specified as a string of comma separated colnames. a leading "-" will reverse the order.

Any other parameters (eg. cascade, private, index, ...) are simply passed through to SQLAlchemy's relation function.

top

create_all

Creates all required tables for all defined entities and relationships.

top

drop_all

Drops all created tables.

top