i have two databases in postgres server named as dispatch and drivers and have configured it like this :
engines = { 'drivers':create_engine('postgres://postgres:admin@localhost:5432/drivers'), 'dispatch':create_engine('postgres://postgres:admin@localhost:5432/dispatch')
}
and also i have routingSession class which based on the object passsed at runtime to the query ,excutes the query at particular database and extract the result
class RoutingSession(Session):
def get_bind(self, mapper=None, clause=None):
if mapper and issubclass(mapper.class_, drivers):
return engines['drivers']
elif mapper and issubclass(mapper.class_, dispatch):
return engines['dispatch']
so now i can post query on database tables like this :
Session = sessionmaker(class_=RoutingSession)
session=Session()
res=session.query(drivers).all()
but the problem i am facing is that i need to do aggreagation of results between my two tables i.e drivers and dispatch ,which i am able to do when working on same database and multiple schemas :
result=session.query(drivers,dispatch).filter(drivers.id==dispatch.id).all()
but fails when i try to do it on different databases.please suggest how can i achieve this .