fastapi_asyncpg icon indicating copy to clipboard operation
fastapi_asyncpg copied to clipboard

Support multiple databases

Open jlrobins opened this issue 2 years ago • 0 comments

Add an additional layer of indirection within app.state so that a single fastapi app wishing to use multiple postgresql databases (via distinct DSNs) can work.

Otherwise the last one calling configure_asyncpg() wins and overwrites app.state.pool.

Now apps can declare multiple database handles with multiple calls to configure_asyncpg() with separate DSNs, then wire up separate Depends() according to which connection pool's transaction is needed for any particular route's parameter.

jlrobins avatar Jan 22 '23 21:01 jlrobins