I've got a chunk of code that started failed as soon as I started
testing with 0.7.
The failure is:
sqlalchemy.exc.StatementError: This Connection is closed '\nCREATE
TABLE bar (\n\ta TEXT NOT NULL\n)\n\n' None
I'll note that the logging indicates that the connection was returned
to the pool *un* closed.
The following code demonstrates the issue.
I am using postgresql 9.0
Is this a bug?
#! /usr/bin/python
# -*- coding: utf-8 -*-
import sys
import logging
import sqlalchemy as sa
import sqlalchemy.orm as sa_orm
logger = logging.getLogger({ '__main__': None }.get(__name__, __name__))
def setup_logging():
logging.basicConfig(stream=sys.stderr, level=logging.WARNING,
format="%(asctime)s:%(levelname)s:%(name)s:%(message)s")
logging.getLogger().setLevel(logging.DEBUG)
logging.getLogger('sqlalchemy').setLevel(logging.DEBUG)
def prep_database(dburi):
engine_opts = dict()
engine_opts['url'] = dburi
session_opts = dict(autoflush=False, autocommit=True)
engine = sa.engine_from_config(engine_opts, prefix='')
factory = sa_orm.sessionmaker(bind=engine, **session_opts)
meta = sa.MetaData()
dbsession = factory()
return (dbsession, meta)
def main():
setup_logging()
dburi = sys.argv[1]
(sess, meta) = prep_database(dburi)
sess.begin()
conn = sess.connection()
if 'bar' not in meta.tables:
sess.begin_nested()
try:
meta.reflect(bind=conn, only=['bar'])
except:
pass
sess.rollback() # not a real rollback
if 'bar' not in meta.tables:
t = sa.Table('bar', meta,
sa.Column('a', sa.TEXT(), nullable=False),
)
t.create(bind=conn)
if 'bar' in meta.tables:
t = meta.tables['bar']
t.drop()
meta.remove(t)
del t
sess.commit()
if __name__ == '__main__':
main()
--
Jon
--
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.