Hello everyone,

I have discovered I can get around the problem I described in 'Bad
updates -- caching problem?' by creating a session at the beginning of
processing each http request, like this:

def handler(req):
   global httpses, session

   Ses=sessionmaker(bind=eng)
   session=Ses()

The thing is, is creating SQLA session costly? Or is it comparable in
cost to session.close()?

The bigger question is, how to *correctly* handle SQLA sessions, for 
data correctness and performance?

Should I do this like this?

1. define Ses=sessionmaker(bind=eng) in module handling SQLA setup, e.g. 
hosts_sqla.py

2. Then in webapp.py:

from hosts_sqla import Ses

And at the beginning of handling each web request do:

session = Ses()

3. after each session.query() do session.close()

?


Regards,
mk


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