On Tue, May 4, 2010 at 2:34 PM, writes_on <[email protected]> wrote:
>
> Mike,
>
> Thanks for the reply!
>
> I guess I'm a little confused (I'm only a so-so database guy), but I thought
> it was a little more difficult than what you describe to make SQLAlchemy
> work in a threaded environment.

As long as you don't share SQLAlchemy connections or sessions between
threads, you should be safe as far as threads go.  A scoped session
(traditionally called ``Session`` with a capital S) is designed for
just this purpose. So that's it for data safety.  But SQLAlchemy might
block in unexpected places; for instance, it generates a couple
initial queries when you first access a table (more or less).

Isn't there a Twisted-SQLAlchemy adapter yet?

You have to know something about which SQLAlchemy commands actually
execute queries.  That takes some experience. ``engine.execute(...)``
and ``Session.execute(...)`` obviously do, as does ``query.all()`` and
``for record in query:``.  But just building up a query doesn't. One
tricky thing is committing ORM objects, which may or may not execute a
query depending on whether its attributes have changed. So anyway,
whenever it does execute queries, that's what you have to put in a
Deferred.

-- 
Mike Orr <[email protected]>

-- 
You received this message because you are subscribed to the Google Groups 
"pylons-discuss" 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/pylons-discuss?hl=en.

Reply via email to