On Feb 5, 2008, at 11:56 AM, braydon fuller wrote:

> I have a Borg that has the db connection and session in it. Do I  
> need to reconnect the connection or close and open a new session for  
> a long running web app?

an example of a typical Session lifecycle as placed in a web  
application is here:

http://www.sqlalchemy.org/docs/04/session.html#unitofwork_contextual_lifespan

theres no "reconnecting" going on explicitly on your end.  the Session  
itself typically lasts for the span of a single web request, after  
which it is either discarded, or closed which releases its resources  
until the next web request where it can be used again.

When using scoped_session(), you automatically get thread local  
behavior out of it so simply calling Session.remove() or  
Session.close() at the end of a request should be sufficient.

So in your code youd want to only call get_database exactly once for  
the entire application, and you'd want to use scoped_session() to  
account for multiple threads.

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"sqlalchemy" group.
To post to this group, send email to sqlalchemy@googlegroups.com
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