Hey,

Michael Bayer wrote:
> On Jun 17, 10:04 am, Martijn Faassen <[EMAIL PROTECTED]> wrote:
>> Hi there,
>>
>> A question came up when thinking about how to integrate SQLAlchemy with
>> Zope.
>>
>> Is it all right to recreate an engine, once per session scope (thread,
>> say), or is it better to reuse the same engine as much as possible? How
>> expensive is engine creation? Do you miss features like, say, connection
>> pooling, if you recreate an engine?
>>
> 
> you should reuse a single engine.  It contains a pool of connections,
> so recreating engines means new connections are constantly rebuilt and
> it defeats the purpose of the pool.  Other than that the creation of
> an engine is not very expensive but even a small expense is needless
> here.

Okay, understood, thanks for the answer!

> I can't think of any advantage to recreating engines on each request
> (except if you're concerned about no-longer-used applications keeping
> their engines around....in which case I'd use a WeakValueDict).

We wouldn't recreate the engine on each request, just each time a 
session is constructed for a new thread (or actually new 
application/thread combination). (that is, ScopedSession would get a 
session_factory that did this).

The reason I'm checking is because it might simplify some initialization 
code if we could just re-create the engine in case a new thread kicks 
in. We'll figure out how to retain a single engine though.

Regards,

Martijn


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