Hi,
On May 22, 2012, at 5:03 PM, Michael Bayer wrote:
> Did a quick experiment, and it appears that a ROLLBACK resets the search
> path. Try calling dbapi_con.commit() in your event handler, that appears
> to cause the search path to remain persistent for the life of that
> connection.
Success!! That was it. Thank you *very much* for your help Michael.
For posterity, the sum of my fix is pasted below. I placed this code before the
database connection was made.
Cheers,
Demitri
---
from sqlalchemy.event import listen
from sqlalchemy.pool import Pool
def my_on_connect(dbapi_con, connection_record):
'''
Callback function to be called at every connection.
dbapi_con - type: psycopg2._psycopg.connection
connection_record - type: sqlalchemy.pool._ConnectionRecord
'''
#print "New DBAPI connection:"#, dbapi_con
cursor = dbapi_con.cursor()
# no schema exists with the same name as the user,
# effectively an empty search path (postgres does not allow
# it to actually be empty
cursor.execute('SET search_path TO "$user"')
dbapi_con.commit()
listen(Pool, 'connect', my_on_connect)
--
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.