gino
gino copied to clipboard
How to use SqlAlchmy @event.lesson_for()?
- GINO version:1.01
- Python version:3.7
- asyncpg version:0.20.1
- aiocontextvars version:
- PostgreSQL version:
Description
I wanted to trigger the sqlALchamy listener event, event.lesson_for, before the execution of gino Query, but it does not seem to be executed.
What I Did
@event.listens_for(Query, "before_compile", retval=True)
def before_compile_query(query):
"""A query compilation rule that will add limiting criteria for every
subclass of HasPrivate"""
print("query===========================")
This will be supported in GINO 1.4/2.0 with SQLAlchemy 1.4/2.0. As this is intended to be solved by future versions, we currently don't have a plan to add this in GINO < 1.4. But please feel free to open PRs to add it if you'll be working with SQLAlchemy 1.3 for some time.