Question

I'm using z3c.saconfig to configure sqlalchemy in a Plone/Zope application. In this application, we created a Session sqlalchemy with named_scoped_session("dbmyapp") z3c.saconfig method. The Session is created and works very well. But we created just one Session for the app.

Can this [one Session sqlalchemy / app] be a bottleneck for app?

By the way, can we create more than one Session per app? Are there any advantages?

snippet of buildout.cfg:

<configure xmlns="http://namespaces.zope.org/zope"
    xmlns:db="http://namespaces.zope.org/db">
    <include package="z3c.saconfig" file="meta.zcml" />

    <db:engine name="dbmyapp" url="oracle://user:pass@hostname:port/sid" />
    <db:session name="dbmyapp" engine="dbmyapp" />
</configure>
Was it helpful?

Solution

The session machinery takes care of providing you with one connection per thread; since you can only execute sequential code within one thread that connection cannot become a bottleneck.

Different parts of the code can request their own session; the session machinery will reuse session connections as required. This is not something you generally have to worry about, that's all handled for you by z3c.saconfig and its dependencies.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top