[sqlalchemy] session query against more databases

2011-07-27 Thread Alessandro
Hi all,
  I'm trying to use session to execute a query against two databases;
is it possibile?

Ex. sql:
 select db1.table1.col1,  db2.table2.col2
   from db1.table1 inner join db2.table2 on db1.table1.key =
db2.table2.key

With sessions:
  session.query(Table1).join(Table2, Table1.key==Table2.key).all()


On internet I found old answers that say it is not possible, but it
was the far 2007.. :-)

Alessandro

-- 
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.



Re: [sqlalchemy] session query against more databases

2011-07-27 Thread Michael Bayer
A single SQL statement cannot emit a query against two distinct database 
connections.There are ways to get a single database connection to access 
two databases behind the scenes using a technology like Oracle's DBLINK.  I'm 
not sure what other vendors provide for this.

This all assumes by database you mean, two different database servers.   If 
you mean different databases or schemas within the same server, that involves 
vendor-specific configurations; check the docs for the database you're using.



On Jul 27, 2011, at 7:21 AM, Alessandro wrote:

 Hi all,
  I'm trying to use session to execute a query against two databases;
 is it possibile?
 
 Ex. sql:
 select db1.table1.col1,  db2.table2.col2
   from db1.table1 inner join db2.table2 on db1.table1.key =
 db2.table2.key
 
 With sessions:
  session.query(Table1).join(Table2, Table1.key==Table2.key).all()
 
 
 On internet I found old answers that say it is not possible, but it
 was the far 2007.. :-)
 
 Alessandro
 
 -- 
 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.
 

-- 
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.