Load a sample models:

New Model
Settings Generate Code Diagram
BLOBCol:
A column for binary data. Presently works only with MySQL, PostgreSQL and SQLite backends.
BoolCol:
Will create a BOOLEAN column in Postgres, or INT in other databases. It will also convert values to "t"/"f" or 0/1 according to the database backend.
CurrencyCol:
Equivalent to DecimalCol(size=10, precision=2).
DateCol:
A date (usually returned as an datetime or mxDateTime object).
DateTimeCol:
A date and time (usually returned as an datetime or mxDateTime object).
DecimalCol:
Base-10, precise number. Uses the keyword arguments size for number of digits stored, and precision for the number of digits after the decimal point.
EnumCol:
One of several string values -- give the possible strings as a list, with the enumValues keyword argument. MySQL has a native ENUM type, but will work with other databases too (storage just won't be as efficient).
FloatCol:
Floats.
IntCol:
Integers.
PickleCol:
An extension of BLOBCol; this column can store/retrieve any Python object; it actually (un)pickles the object from/to string and stores/retrieves the string.
StringCol:

A string (character) column. Extra keywords:

length:
If given, the type will be something like VARCHAR(length). If not given, then TEXT is assumed (i.e., lengthless).
varchar:
A boolean; if you have a length, differentiates between CHAR and VARCHAR, default True, i.e., use VARCHAR.
UnicodeCol:
A subclass of StringCol. Also accepts a dbEncoding keyword argument, which defaults to "UTF-8". Values coming in and out from the database will be encoded and decoded.
Note: parameters in queries will not be automatically encoded, so if you do a query matching a UnicodeCol column you must apply the encoding yourself.
table:
The name of the table in the database. This is derived from style and the class name if no explicit name is given. If you don't give a name and haven't defined an alternative style, then the standard MixedCase to mixed_case translation is performed.
idName:
The name of the primary key column in the database. This is derived from style if no explicit name is given. The default name is id.

The ForeignKey class should be used instead of Col when the column is a reference to another table/class. It is generally used like ForeignKey('Role'), in this instance to create a reference to a table Role. This is largely equivalent to Col(foreignKey='Role', sqlType='INT'). Two attributes will generally be created, role, which returns a Role instance, and roleID, which returns an integer ID for the related role.

One-to-Many relationtionship
One-to-One relationtionship
Many-to-Many relationtionship