Module: perform_ddl
DDL statements for Elixir.
Entities having the perform_ddl statement, will automatically execute the given DDL statement, at the given moment: ether before or after the table creation in SQL.
The 'when' argument can be either 'before-create' or 'after-create'. The 'statement' argument can be one of: - a single string statement - a list of string statements, in which case, each of them will be executed
in turn.
- a callable which should take no argument and return either a single string or a list of strings.
In each string statement, you may use the special '%(fullname)s' construct, that will be replaced with the real table name including schema, if unknown to you. Also, self explained '%(table)s' and '%(schema)s' may be used here.
You would use this extension to handle non elixir sql statemts, like triggers etc.
class Movie(Entity): title = Field(Unicode(30), primary_key=True) year = Field(Integer) perform_ddl('after-create', "insert into %(fullname)s values ('Alien', 1979)")
preload_data is a more specific statement meant to preload data in your entity table from a list of tuples (of fields values for each row).
class Movie(Entity): title = Field(Unicode(30), primary_key=True) year = Field(Integer) preload_data(('title', 'year'), [(u'Alien', 1979), (u'Star Wars', 1977)]) preload_data(('year', 'title'), [(1982, u'Blade Runner')]) preload_data(data=[(u'Batman', 1966)])
