Michael Bayer wrote:
We have engines set up like:
engine1 = create_engine('mysql://username:passw...@server/db1')
engine2 = create_engine('mysql://username:passw...@server/db2')
..and then have them bound to separate sessions, with separate model classes
mapped to them.
Now, mysql supports cross database joins, eg:
select t1.colwhatever
from db1.table1 as t1,db2.table2 as t2
where t1.something=t2.something
Is it possible to express that in SQLAlchemy, particularly at the ORM layer
with the multiple session/engine/model setup described above?
(I suppose the case to test would be, if ModelA is bound to engine1 and ModelB
is bound to engine2, how would we do:
session.query(ModelA,ModelB,ModelA.something==ModelB.something)
...or something similar, if the above isn't possible?
its not possible across two distinct database connections, no. Only the
database can do joins, and that requires a single connection session to do so.
Right, but how can I create an engine such that it can be used to access
two databases? Is it as simple as setting the __tablename__ as
'db.tablename' rather than just 'tablename'?
Chris
--
You received this message because you are subscribed to the Google Groups
"sqlalchemy" group.
To post to this group, send email to sqlalch...@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.