On 08/17/2010 01:44 PM, fulv wrote:
> This is my stack:
>
> -   Mac OS X 10.6.4
> - freeTDS 0.82
> - unixODBC 2.3.0
> - pyodbc 2.1.7
> - z3c.saconfig 0.11
> - SQLAlchemy 0.6.3
> - Zope 2.10.11
> - Plone 3.3.5
>
> I have a control panel in my application that allows to change the
> connection parameters, i.e. generate a new connection string.  I'm
> trying to "dirty" the Session or Engine or both, so that when the
> connection string changes, the session does not use the old Engine,
> but will create a new one.
>
> This is what I do now when the connection parameters change:
>
> from z3c.saconfig import Session
> from z3c.saconfig.interfaces import IEngineFactory
> from zope.component import getUtility
>
> getUtility(IEngineFactory, name='').reset()
> Session().expire_all()
> Session().remove()
>
> Clearly, this is not enough, because the Session keeps using the old
> Engine.  Any tips would be appreciated!
>
> Thanks!
>
>   

In vanilla SQLAlchemy (w/o Zope addons), you could do this:

Session.remove() # NOTE: No parens after Session
Session.configure(bind=<new engine object>)

Also, are you sure your IEngineFactory object is returning the correct
engine? The default EngineFactory class does not seem to have a public
API for changing engine args. Otherwise, that should be enough.

-Conor

-- 
You received this message because you are subscribed to the Google Groups 
"sqlalchemy" group.
To post to this group, send email to sqlalch...@googlegroups.com.
To unsubscribe from this group, send email to 
sqlalchemy+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/sqlalchemy?hl=en.

Reply via email to