Hi there, I try to create a m:n relation. All tables should be reflected from an existing db. For this I have the following construct: engine = EngineFactory(DSN, echo=False, convert_unicode=True, encoding="latin1" )() Base = declarative_base(engine) Base.metadata.reflect() tables = Base.metadata.tables
class tblPersonCompanyTable(Base): implements(interfaces.ItblPersonCompanyTable) __table__ = tables['tblPersonCompany'] class tblPersonTable(Base): __table__ = tables['tblPerson'] class tblCompanyTable(Base): __table__ = tables['tblCompany'] related_persons = orm.relation(tblPersonTable, secondary=tblPersonCompanyTable, backref="company") class tblFlagTable(Base): __table__ = tables['tblFlag'] now when I create a tblFlagTable object (which is the first thing accessing the db), I get an error: AttributeError: 'tblPersonCompanyTable' object has no attribute 'foreign_keys' the MySQL-table assigned to 'tblPersonCompanyTable' does have foreign keys assigned. what am I doing wrongly? how can I fix this thanks robert File "/home_2/zope/energiecluster/db/scripts/transfer/transfer.py", line 223, in ? main() File "/home_2/zope/energiecluster/db/scripts/transfer/transfer.py", line 173, in main fo = tblFlagTable() File "/home_2/zope/energiecluster/db/scripts/transfer/<string>", line 4, in __init__ File "/usr/local/lib/python2.4/site-packages/SQLAlchemy-0.5.0rc4-py2.4.egg/sqlalchemy/orm/attributes.py", line 858, in initialize_instance fn(self, instance, args, kwargs) File "/usr/local/lib/python2.4/site-packages/SQLAlchemy-0.5.0rc4-py2.4.egg/sqlalchemy/orm/mapper.py", line 1726, in _event_on_init instrumenting_mapper.compile() File "/usr/local/lib/python2.4/site-packages/SQLAlchemy-0.5.0rc4-py2.4.egg/sqlalchemy/orm/mapper.py", line 679, in compile mapper._post_configure_properties() File "/usr/local/lib/python2.4/site-packages/SQLAlchemy-0.5.0rc4-py2.4.egg/sqlalchemy/orm/mapper.py", line 701, in _post_configure_properties prop.init(key, self) File "/usr/local/lib/python2.4/site-packages/SQLAlchemy-0.5.0rc4-py2.4.egg/sqlalchemy/orm/interfaces.py", line 404, in init self.do_init() File "/usr/local/lib/python2.4/site-packages/SQLAlchemy-0.5.0rc4-py2.4.egg/sqlalchemy/orm/properties.py", line 575, in do_init self._determine_joins() File "/usr/local/lib/python2.4/site-packages/SQLAlchemy-0.5.0rc4-py2.4.egg/sqlalchemy/orm/properties.py", line 649, in _determine_joins self.secondaryjoin = _search_for_join(self.mapper, self.secondary) File "/usr/local/lib/python2.4/site-packages/SQLAlchemy-0.5.0rc4-py2.4.egg/sqlalchemy/orm/properties.py", line 642, in _search_for_join return join_condition(mapper.local_table, table) File "/usr/local/lib/python2.4/site-packages/SQLAlchemy-0.5.0rc4-py2.4.egg/sqlalchemy/sql/util.py", line 82, in join_condition for fk in b.foreign_keys: --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "sqlalchemy" group. To post to this group, send email to sqlalchemy@googlegroups.com To unsubscribe from this group, send email to sqlalchemy+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/sqlalchemy?hl=en -~----------~----~----~----~------~----~------~--~---