[sqlalchemy] get referencing foreign table + column

2015-06-18 Thread Richard Gerd Kuesters
hello all! i think this is a quick question: is there a way to get the 
referencing table and column from a given foreign key column, rather 
then list(col.impl.parent_token.expression.foreign_keys)[0] ?


best regards,
richard.

--
You received this message because you are subscribed to the Google Groups 
sqlalchemy group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sqlalchemy+unsubscr...@googlegroups.com.
To post to this group, send email to sqlalchemy@googlegroups.com.
Visit this group at http://groups.google.com/group/sqlalchemy.
For more options, visit https://groups.google.com/d/optout.
attachment: richard.vcf

Re: [sqlalchemy] get referencing foreign table + column

2015-06-18 Thread Mike Bayer



On 6/18/15 1:20 PM, Richard Gerd Kuesters wrote:
hello all! i think this is a quick question: is there a way to get the 
referencing table and column from a given foreign key column, rather 
then list(col.impl.parent_token.expression.foreign_keys)[0] ?


You can call the .foreign_keys accessor straight off the mapped attribute:

 B.a_id.foreign_keys
set([ForeignKey('a.id')])

in relational DBs there is of course no the referencing table because 
a column can be referenced, or reference, multiple constraints / columns 
/ tables.








best regards,
richard.
--
You received this message because you are subscribed to the Google 
Groups sqlalchemy group.
To unsubscribe from this group and stop receiving emails from it, send 
an email to sqlalchemy+unsubscr...@googlegroups.com 
mailto:sqlalchemy+unsubscr...@googlegroups.com.
To post to this group, send email to sqlalchemy@googlegroups.com 
mailto:sqlalchemy@googlegroups.com.

Visit this group at http://groups.google.com/group/sqlalchemy.
For more options, visit https://groups.google.com/d/optout.


--
You received this message because you are subscribed to the Google Groups 
sqlalchemy group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sqlalchemy+unsubscr...@googlegroups.com.
To post to this group, send email to sqlalchemy@googlegroups.com.
Visit this group at http://groups.google.com/group/sqlalchemy.
For more options, visit https://groups.google.com/d/optout.