dgilland / sqlservice

The missing SQLAlchemy ORM interface.
https://sqlservice.readthedocs.io
MIT License
179 stars 9 forks source link

Multiple databases support #38

Closed tabebqena closed 2 years ago

tabebqena commented 2 years ago

Hello,

Is there is ability to support multiple database per session, that is discussed here

engine1 = create_engine('postgresql://db1')
engine2 = create_engine('postgresql://db2')

Session = sessionmaker()

# bind User operations to engine 1, Account operations to engine 2
Session.configure(binds={User:engine1, Account:engine2})

session = Session()

I can't figure out how to pass options to achieve this behavior.

dgilland commented 2 years ago

There's nothing built into sqlservice that does this but seems like one possible solution could be to create a new Database-like class that accepts multiple Database instances along with the session binds and then configures its own session per the method described.