So, if I understand this right, I could import a "base" module that does a lazy creation of the Base class with a metadata object and then just use that base class everywhere I need it for the declarative class definitions. Then at a later time (before I use the mapped classes), I could go and "bind" the metadata for the Base class to an engine for use.
Correct? (I apologize if I used the terms incorrectly). If this is true, then I think I see how I can solve my problem. -Allen On Sun, Apr 27, 2008 at 6:28 PM, Michael Bayer <[EMAIL PROTECTED]> wrote: > > > On Apr 27, 2008, at 8:25 AM, Allen Bierbaum wrote: > > > The problem that as I understand it, to use declarative, you can't > > import an module that defines a table-based object until after some > > initialization code has been run to connect to a database and create a > > 'Base' class for the declarative layer. > > This is not true; the declarative extension serves as a holding zone > for a MetaData object; like the MetaData object, it requires no > association to any database engine at any time. The initial example > in the declarative docunentation, which I am going to change right > now, illustrates the engine being associated with the underlying > MetaData as just as an example. The only time a databse connection > is needed is when you are ready to query the database. You can > create your Session and bind it to a newly created engine right before > the first query is issued, if you like. > > > > > --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---