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