Hi,

I just tried out SQLAlchemy 0.4.4 on a simple project - the front end
for a vending machine.  It uses two MySQL database connections.  I've
used the session/transaction facilities so I can use SQLAlchemy's two-
phase commit to create a transaction spanning both databases.  It's
working, but I'm having to do more things than I think I should be
doing, so I'm not sure if I'm misunderstanding SQLAlchemy or have
something set up incorrectly.

First, according to the SQLAlchemy 0.4 release notes, it should be
possible to commit the session and have the changes take effect, but
I'm still needing to manually commit the transaction.  I'm doing it
like this:

transaction = session.begin()
... do stuff ...
transaction.commit()
session.commit()

It also works when the two commit calls are reversed.  Without the
transaction.commit(), the data gets saved to the database but is not
visible outside the session; is the transaction not committing or is
it a nested transaction?

Second, I'm having to call session.close() to get updated data outside
an explicit transaction, when I thought creating the sessionmaker with
autoflush=True should cause an update to occur every time I make a
query.  Calling session.flush() does not help, regardless of whether I
specify autoflush.

The code is pretty short.  Please let me know if there's anything I'm
doing wrong here.

Definitions (yes, I realize there's a password in there):

http://www.acm.uiuc.edu/projects/SIGArch/browser/sucrose/trunk/python/mysql/db.py

Usage (see Sucrose.vend):

http://www.acm.uiuc.edu/projects/SIGArch/browser/sucrose/trunk/python/api/sucrose.py

Thanks,

--Nicholas

--~--~---------~--~----~------------~-------~--~----~
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