Hi Michael,

On May 18, 2012, at 9:19 AM, Michael Bayer wrote:

> When using cross-schema reflection, you have the option of either using only 
> "public" in your schema search path, or *not* schema-qualifying the tables.  
> This is because when you have the alternate schemas in your search path, 
> Postgresql does not tell SQLAlchemy about the schema name when it returns 
> foreign key information - it returns just the tablename, columnnname, but not 
> the schema. Therefore when you have your Table objects which schema names in 
> them, SQLAlchemy can't match them up and instead makes another Table that you 
> aren't seeing as the target of each cross-schema foreign key, which has no 
> schema name.

Thanks for the explanation. This unfortunately makes things difficult for me as 
I have at least two schema that have nearly the same tables, the schema model 
providing a clean separation of the data. Removing the schema from search_path 
introduces ambiguities.

Where would be the best place to try to find a solution? Is it psycopg2 that's 
not returning the schema information? The information is of course in the 
database, so it sounds like maybe the SQL query to get the foreign keys could 
be updated to explicitly include the schema? I imagine it's not at the database 
level since, again, the information is there.

Also, given the Python classes in my example code, how do I print out the 
foreign keys from a table object?

Cheers,
Demitri

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

Reply via email to