Trying to use event listeners(https://docs.sqlalchemy.org/en/14/core/events.html#sqlalchemy.events.ConnectionEvents
) on a async sqlalchemy engine and am getting this error:
{NotImplementedError}asynchronous events are not implemented at this time. Apply synchronous listeners to the AsyncEngine.sync_engine or AsyncConnection.sync_connection attributes.
If I'm understanding this correctly I cant use events on an async engine and I have to switch to a sync engine if I want event support?
engine: Engine = create_async_engine(
URL, echo=True, future=True
)
async_session = sessionmaker(
engine, class_=AsyncSession, expire_on_commit=False, future=True
)
event.listens_for(engine, "do_connect")(do_connect_listener)
event.listens_for(engine, "engine_connect")(engine_connect_listener)