Sqlalchemy seems to commit changes when it's not supposed to
Consider the following snippet of Python code:
from sqlalchemy import *
from sqlalchemy.orm import *
db = create_engine('postgresql:///database', isolation_level='SERIALIZABLE')
Session = scoped_session(sessionmaker(bind=db, autocommit=False))
s = Session开发者_运维百科()
s.add(SomeInstance())
s.flush()
raw_input('Did it work? ')
It connects to the database, adds SomeInstance
to the session, flushes, and then pauses. At this point, if I psql into my database, I would see that the instance has already been inserted -- even though autocommit is False and I haven't committed the session yet!
Any idea what I might be doing wrong?
Thanks!
Nevermind, there was a bug in the psycopg2.py implementation in sqlalchemy 0.6.3; upgrading to 0.6.4 solved this problem.
精彩评论