Hi -

This is a general clarification question.  I have read the docs, but
am still a little unclear on the exact relationship between sessions,
engines, and connections -- at least as this concerns thread safety.

Background:  I'm using sqlalchemy in a web application context
(cherrypy) and hence figure that I should make sure that I'm doing
things in a thread-safe way :)

Currently, I am just creating a "normal" engine and then using that to
initialize a scoped session.  (I am setting Session =
scoped_session(sessionmaker(...., bind=engine)).  I understand that
this is the way to ensure that Session instances are thread-local.

Now, if I want to do some stuff with the engine or connection
directly, should I create my engine with context="threadlocal"
additionally?  (And then pass that threadlocal engine off to my
scoped_session ?)

And when I get a connection from such an engine, do I need to always
specify that I want a contextual connection?  i.e. conn =
engine.contextual_connect() ?  (What happens if I just run
engine.connect() as "normal" with a threadlocal connection?)

I assume all of this is necessary in a multi-threaded environment?

Thanks for the help!

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