I have a number of database that have the same tables in them.

I create a session for 1 data and do some work. This work causes
a number of table table object to be reflected from the database
and then mapped. This works fine.

Now I Switch to another database which has the same tables. If I
access only table that had been mapped in first database
things go fine. If I try to map a new table this is where
problems start with it not handling the relation. The
mapper when compiled says the following:

ArgumentError: Could not determine join condition between parent/child tables on
relation mds_ltc_mi.stx_setup.  Specify a 'primaryjoin' expression.  If this is
a many-to-many relation, 'secondaryjoin' is needed as well.

If I access the same table/mapped object in the first database thing
work just fine. It pickup the foreign keys and everything work just fine


All session are created as follows:
self._engine = create_engine(url,pool_recycle=14400, echo=debug)
self.metadata = MetaData()
self.metadata.bind = self._engine
self.session = Session(bind=self._engine, autoflush=False,
   _enable_transaction_accounting=False, autocommit=True,
   weak_identity_map=True)


Mapping code look like the following:

mapped_class = class_mapper(map_class, compile=False, raiseerror=False)
if mapped_class:
     return mapped_class

if map_class.__table_name__ in self.metadata.tables:
     table = self.metadata.tables[map_class.__table_name__]
else:
     table = Table(name, self.metadata, autoload=True)

mapped_class = mapper(map_class, table, mapping_option)
mapped_class.compile()
return mapped_class


-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________
Sqlalchemy-users mailing list
Sqlalchemy-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/sqlalchemy-users

Reply via email to