fastapi_asyncpg
fastapi_asyncpg copied to clipboard
Support multiple databases
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.