Skip to content

SQLAlchemy Core events #435

@tng10

Description

@tng10
  • GINO version: 0.8.1
  • Python version: 3.6.6
  • asyncpg version: 0.18.2
  • aiocontextvars version: 0.2.1
  • PostgreSQL version: 10.6

Description

Hello, I would like to know if it is possible to use SQLAlchemy Core Events with Gino.

It would be really great to use DDLEvents

events.py

from sqlalchemy import event
from app.models import UserModel

def after_create_method(target, connection, **kw):
    print('some routine...')

event.listen(UserModel.__table__, "after_create", after_create_method)

create_user_example.py

async def create_user(validated_data):
    instance = await UserModel.create(**validated_data)
    return instance

I've managed to register a listener by passing table attribute, but unfortunately the function doesn't get invoked once the UserModel.create gets called. Can someone help me on that?

I've seen gino.Crud.CRUDModel.create is the class responsible for creating a record on the database. In case we are moving forward with this issue, is it possible to come up with SQLAlchemy events on this method/class?

Thanks in advance!

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions