This patch optionally allows the user to create tables in strict sequence.
When using the usual table() method to create lots of tables with foreign keys, I have sometimes seen table creation fail with a message saying the referenced table does not exist. This is using PostgreSQL 8.2; other DBs may not exhibit this behaviour.
This appears to be a rare race condition somewhere in the interaction between the DB, the access library, SQLAlchemy and sAsync. Once the tables are created successfully, everything seems to work normally.
This patch adds two new methods to the AccessBroker object: autoTable() and finishedCreatingTables().
One uses autoTable() exactly as one uses table() within startup(), but one appends a call to finishedCreatingTables() at the end of the method. This returns a deferred which fires with a list of 2-tuples, much as using a DeferredList? would.
For example:
def startup ( self ):
self.autoTable (
'foo',
C ( 'foo1', sa.Integer, primary_key = True ),
C ( 'foo2', sa.String() ),
)
self.autoTable (
'bar',
C ( 'bar1', sa.Integer, primary_key = True ),
C ( 'bar2', sa.String() ),
)
return self.finishedCreatingTables()