On 8/4/2010 10:03 PM, Mike Conley wrote:


On Wed, Aug 4, 2010 at 9:39 PM, Michael Hipp <[email protected]
<mailto:[email protected]>> wrote:

    Can someone tell me why this code won't create any tables? The
    tables are defined in another file that calls declarative_base().

    I presume the problem is that it doesn't know which tables to
    create. If so, how do I tell it what tables to create?

    Base = declarative_base()
    database = 'sqlite:///convert/db.sqlite'
    engine = create_engine(database, echo=True)
    metadata = Base.metadata
    metadata.create_all(engine)  # Does nothing, says nothing
    Session = sessionmaker()
    Session.configure(bind=engine)

    Thanks,
    Michael


Well, metadata here doesn't refer to the metadata that holds table
definitions.

What about something like

import otherfile
Base = otherfile.Base    # assuming you use Base = declarative_base() in
otherfile

Thanks. But by the time I'm done there will be at least a dozen of those "otherfiles". Which one do I get Base from?

Thanks,
Michael

--
You received this message because you are subscribed to the Google Groups 
"sqlalchemy" group.
To post to this group, send email to [email protected].
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