How to implement global database connection pool with databases wrapper and set the schema at run time in a schema based multi tenant app #1040
Unanswered
cs-satish-mishra
asked this question in
Q&A
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
How can I implement a safe and efficient global database connection pool in a multi-tenant application using the PostgreSQL Schema-based approach, FastAPI, and asyncpg (databases wrapper)? Specifically, I need to dynamically set the appropriate schema in connection or query based on the API subdomain or headers received from the request at runtime. How can I achieve this?
In the above sample code, I want to safely set the intended schema at the time of query but utilizing same global connection pool.
I am aware of sqlalchemy schema translation map but do not know how I can achieve similar with databases wrapper and connection pool.
Beta Was this translation helpful? Give feedback.
All reactions