Skip to content
This repository was archived by the owner on Aug 19, 2025. It is now read-only.
This repository was archived by the owner on Aug 19, 2025. It is now read-only.

Async connection created callback #321

@alicederyn

Description

@alicederyn

I need to issue a set of SQL commands at the start of each connection, e.g. to set up the search path. Currently it looks like this can only be done by subclassing Database and completely reimplementing its connection method to return a subclass of Connection that overrides __aenter__. Would it be acceptable to add something akin to Django's connection_created signal? Syntax might look like

@db.connection_created
async def set_search_path(connection):
  await connection.execute("set search_path = my_schema")

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions