Hi,
When calling create_all on a metadata instance after a session has alrady
been opened causes the create_all to hang, I assume because the session is
blocking the create_all. Is there some way to get create_all to use the
existing session, or any other graceful way around this? Thanks.
I guess another option is to close and then reopen the session after the
create_all has been called, but I'd prefer not to do that if possible.
Regards, Faheem.
##########################################################################
from sqlalchemy import *
from sqlalchemy.orm import *
from sqlalchemy import MetaData
meta = MetaData()
def make_foo(meta):
foo = Table(
'foo', meta,
Column('id', Integer, nullable=False, primary_key=True),
)
return foo
def make_bar(meta):
bar = Table(
'bar', meta,
Column('id', Integer, ForeignKey('foo.id', onupdate='CASCADE',
ondelete='CASCADE'), nullable=False, primary_key=True),
)
return bar
dbuser =
password =
dbname =
dbstring = "postgres://%s:%...@localhost:5432/%s"%(dbuser, password, dbname)
from sqlalchemy import create_engine
db = create_engine(dbstring)
meta.bind = db
db.echo = 'debug'
make_foo(meta)
meta.create_all()
Session = sessionmaker()
session = Session(bind=db)
session.execute("select * from foo;")
make_bar(meta)
meta.create_all()
--
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.