SQLAlchemy uses the foreign key not only to locate referenced rows, but to
connect them when adding rows, so using an OR in your foreign key isn't
going to work long-term, because if you create the relationship via
SQLAlchemy, it is not going to be able to determine how to connect the
foreign key links.
This is really a many-to-many relationship between Employees and
Specialties.
You are better off reworking this to use a relation table 'emp_specialty':
table_employees = sa.Table('employees', metadata,
sa.Column('id', pg.PGInteger(), primary_key=True),
sa.Column('fullname', pg.PGInteger())
)
table_specialities = sa.Table('specialities', metadata,
sa.Column('id', pg.PGInteger(), primary_key=True),
sa.Column('name', pg.PGString(255)),
)
table_emp_specialty = sa.Table('emp_specialties', metadata,
sa.Column('idemp', pg.PGInteger(), sa.ForeignKey('employees.id'),
sa.Column('idspeciality', pg.PGInteger(),
sa.ForeignKey('specialities.id'))
)
and then using the Many-to-Many relation pattern of SQLAlchemy:
http://www.sqlalchemy.org/docs/04/mappers.html#advdatamapping_relation_patterns_manytomany
I believe there's an example in the examples that shows something similar
using the pattern.
Rick
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---