Is there a way to connect through multiple sessions in sqlalchemy?

If I have multiple sessions for different databases, is there a way to combine them on the same query?

For example, I integrate two programs with a table in the middle to translate an identifier from one to another. I'm currently just trying to run individual queries, creating the next one, using the data from the previous one. It seems to be getting a little dirty, and I would like to do this in one request.

I did not find anything that says it is possible, and knowing that the request is being executed in the session itself, makes me think that this may not be.

thanks

+5
python join session sqlalchemy
source share
1 answer

If these are truly separate database servers, you need to use a system such as dblink to set up a transparent proxy from one database to another. Otherwise, if these databases are on the same server, there is usually a way to refer to tables in other schemas / databases, but it depends heavily on the type of database used.

But in any case, these routines will include the ability to address all databases on one connection, which means in one session. If you cannot do this in a single SQL statement, then you cannot use SQL JOIN, you will need to collect data in memory.

+2
source share

All Articles