On May 21, 2012, at 8:05 PM, Demitri Muna wrote:
> Hi Michael,
>
> As a very quick test to see if I could make things work, I created a new
> postgres user and set that user's search_path to just '"$user"' (since it
> can't be empty, but as there are no tables with the user's name, that's
> effectively what it is). My toy example worked.
>
> On May 18, 2012, at 5:10 PM, Michael Bayer wrote:
>
>> If you've created all your Table objects with an explicit "schema"
>> definition, you shouldn't need anything in your search path - technically
>> not even "public". If the issue is that your database connection defaults
>> to a certain search path, change the search path just within your SQLAlchemy
>> application to not include defaults. A "connect" event listener can
>> achieve this.
>
> I'm trying to avoid creating a separate user just for scripts that use SA and
> it sounds like your suggestion above should address this, but I'm a little
> stuck on how that will work. This is what I have:
>
> def my_on_connect(dbapi_con, connection_record):
> print "New DBAPI connection:", dbapi_con
> # ??? execute query 'SET search_path TO "$user"'
should be able to execute with a cursor:
cursor = dbapi_con.cursor()
cursor.execute('SET search_path TO "$user"')
>
> http://www.mail-archive.com/[email protected]/msg09859.html
>
> but that didn't work. I first make the database connection and then later
> define my table classes through autoload, and it seemed to have a problem
> with that order (I think I got a "table not found" error upon
> metadata.reflect().)
OK table not found would be affected based on the search path and whether or
not you have "schema" on your table.
--
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.