Skip to content
Discussion options

You must be logged in to vote

Figured it out. The key was to just use the binds parameter in AsyncSessionConfig:

# config
-class RoutingSession(Session):
-    def get_bind(self, mapper=None, clause=None):
-        if mapper:
-            return get_settings().db.engines[mapper.class_.__bind_key__].sync_engine
-        return None
-
-session_factory = async_sessionmaker(sync_session_class=RoutingSession, expire_on_commit=False)
+session_config = AsyncSessionConfig(
+    expire_on_commit=False,
+    autoflush=False,
+    binds=settings.db.binds,  # type: ignore[arg-type]
+)
alchemy_configs = SQLAlchemyAsyncConfig(
    engine_instance=get_settings().db.engines["cache_db"], # Never gets called right now
-    session_maker…

Replies: 2 comments

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Answer selected by moconnor-oled
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
1 participant