On Mar 31, 2008, at 3:54 PM, Nicholas Riley wrote:
> I tried setting the isolation level explicitly, but it didn't help:
>
> In [29]: self.session.close()
> In [30]: self.db._acm.execute('SET SESSION TRANSACTION ISOLATION LEVEL
> READ COMMITTED')
> In [31]: self.db._sucrose.execute('SET SESSION TRANSACTION ISOLATION
> LEVEL READ COMMITTED')
> In [32]: self.balance_from_uid(25482)
> 2008-03-31 14:44:12,023 INFO sqlalchemy.engine.base.Engine.0x..34
> SELECT users.uid AS users_uid, users.netid AS users_netid, users.uin
> AS users_uin
> FROM users
> WHERE users.uid = %s ORDER BY users.uid
> LIMIT 0, 1
> 2008-03-31 14:44:12,023 INFO sqlalchemy.engine.base.Engine.0x..34
> [25482]
> 2008-03-31 14:44:12,029 INFO sqlalchemy.engine.base.Engine.0x..34
> SELECT vending.uid AS vending_uid, vending.balance AS vending_balance
> FROM vending
> WHERE vending.uid = %s
> 2008-03-31 14:44:12,029 INFO sqlalchemy.engine.base.Engine.0x..34
> [25482L]
> Out[32]: 99.5
>
> -- change the balance to 100 elsewhere --
>
> In [33]: self.balance_from_uid(25482)
> 2008-03-31 14:44:22,369 INFO sqlalchemy.engine.base.Engine.0x..34
> SELECT users.uid AS users_uid, users.netid AS users_netid, users.uin
> AS users_uin
> FROM users
> WHERE users.uid = %s ORDER BY users.uid
> LIMIT 0, 1
> 2008-03-31 14:44:22,369 INFO sqlalchemy.engine.base.Engine.0x..34
> [25482]
> Out[33]: 99.5
>
> Is this a MySQL issue (I tried READ UNCOMMITTED too) or is there some
> other way to get updated data without closing the session?
The other thing you're probably hitting here is that the Session is
going to cache everything it loads until you clear out its data
(session.clear()) , or expire the data that it has loaded
(session.expire_all()). This is why it tends to work more nicely with
"transactional=True" in that regard. The pattern in your application
of creating one global session might be better be served by creating
sessions per unit of work, i.e. on an as-needed basis (or perhaps
within the scope of your Sucrose object). If its not a web
application, where the boundaries for creating sessions are very
simple (i.e. once per request), then you have to figure out what
boundaries you want to have amongst concurrent processes in your
application.
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---