alex bodnaru wrote:
> 
> hi friends,
> 
> i wish to insert some initial data in a few management tables (like 
> applications
> groups, roles etc).
> 
> is there a way to register dml to be done after create_all ends?
> 
> i'd specifically like it to happen after the entire ddl dust reaches the 
> ground.

MetaData and Tables emit DDL events that you can listen for with
.append_ddl_listener.

http://www.sqlalchemy.org/docs/04/sqlalchemy_schema.html#docstrings_sqlalchemy.schema_MetaData

Here's an example insert-after-CREATE function from the SA test suite:

def fixture(table, columns, *rows):
    """Insert data into table after creation."""
    def onload(event, schema_item, connection):
        insert = table.insert()
        column_names = [col.key for col in columns]
        connection.execute(insert,
                           [dict(zip(column_names, column_values))
                            for column_values in rows])
    table.append_ddl_listener('after-create', onload)


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"sqlalchemy" group.
To post to this group, send email to sqlalchemy@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/sqlalchemy?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to