class FakeConnection:
async def execute(self, query: str, **arguments):
return "result"
@app.before_server_start
async def setup_db(app, _):
app.ctx.db_conn = FakeConnection()
def get_db(request: Request):
return request.app.ctx.db_conn
ext.injection(FakeConnection, get_db) # how to import ext.injection
@app.get("/")
async def handler(request, conn: FakeConnection):
response = await conn.execute("...")
return text(response)
I could not find the correct injection location using PyCharm’s auto_import