We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
While at it, also move from initializing app with session maker in each command, but provide a global application object.
Redo settings.DATABASE -> settings.DATABASES and provide global variable connections, in the same manner as Django
ConnectionHandler is a wrapper around project sessionmaker(s). This will be a step for #21 https://docs.sqlalchemy.org/en/20/orm/extensions/asyncio.html
# using example from "Custom Vertical Partitioning" import random from sqlalchemy.ext.asyncio import AsyncSession from sqlalchemy.ext.asyncio import create_async_engine from sqlalchemy.ext.asyncio import async_sessionmaker from sqlalchemy.orm import Session # construct async engines w/ async drivers engines = { 'leader':create_async_engine("sqlite+aiosqlite:///leader.db"), 'other':create_async_engine("sqlite+aiosqlite:///other.db"), 'follower1':create_async_engine("sqlite+aiosqlite:///follower1.db"), 'follower2':create_async_engine("sqlite+aiosqlite:///follower2.db"), } class RoutingSession(Session): def get_bind(self, mapper=None, clause=None, **kw): # within get_bind(), return sync engines if mapper and issubclass(mapper.class_, MyOtherClass): return engines['other'].sync_engine elif self._flushing or isinstance(clause, (Update, Delete)): return engines['leader'].sync_engine else: return engines[ random.choice(['follower1','follower2']) ].sync_engine # apply to AsyncSession using sync_session_class AsyncSessionMaker = async_sessionmaker( sync_session_class=RoutingSession )
The text was updated successfully, but these errors were encountered:
No branches or pull requests
While at it, also move from initializing app with session maker in each command, but provide a global application object.
Redo settings.DATABASE -> settings.DATABASES and provide global variable connections, in the same manner as Django
ConnectionHandler is a wrapper around project sessionmaker(s). This will be a step for #21
https://docs.sqlalchemy.org/en/20/orm/extensions/asyncio.html
The text was updated successfully, but these errors were encountered: