On Wed, Aug 4, 2010 at 9:39 PM, Michael Hipp <mich...@hipp.com> 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 then continue as your in sample from "database =". This should give you access to metadata from the other file. -- You received this message because you are subscribed to the Google Groups "sqlalchemy" group. To post to this group, send email to sqlalch...@googlegroups.com. To unsubscribe from this group, send email to sqlalchemy+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/sqlalchemy?hl=en.