I have a scenario where one column in a table is involved in two foreign 
keys. Getting some erronous results, pondering whether it is currently 
supported. The code below explains the point.

from sqlalchemy import *
from sqlalchemy.ext.assignmapper import assign_mapper
from sqlalchemy.ext.sessioncontext import SessionContext

context = SessionContext(create_session)
metadata = BoundMetaData('postgres://username:[EMAIL PROTECTED]/mydb', 
echo=True)

company_tbl = Table('company', metadata,
    Column('company_id', Integer, primary_key=True),
    Column('name', Unicode(30)))

employee_tbl = Table('employee', metadata,
    Column('company_id', Integer, primary_key=True),
    Column('emp_id', Integer, primary_key=True),
    Column('name', Unicode(30)),
    Column('reports_to', Integer),
    ForeignKeyConstraint(['company_id'], ['company.company_id']),
    ForeignKeyConstraint(['company_id', 'reports_to'], 
['employee.company_id', 'employee.emp_id']))

metadata.create_all()

This code does not work for me.

After creating the database manually and setting the mapping, I got some 
error like this - ArgumentError: Cant determine relation direction 
'set([])'...

Need help. Thanks.

Sanjay



-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys -- and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
Sqlalchemy-users mailing list
Sqlalchemy-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/sqlalchemy-users

Reply via email to