tortoise / tortoise/tortoise-orm

Database event hooks

Open
#591 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Python
Stars
5.6k
Forks
516
Avg merge
2d 21h
Merged PRs (30d)
9

Description

Is your feature request related to a problem? Please describe.
I want to add metrics to database (query times, exceptions, create|delete calls, etc.)

Describe the solution you'd like
It would be great to have something like hooks into db functions.

Describe alternatives you've considered
So far I have considered monkey pathing using decorators, but it seems like a very bad practice.

Additional context
SQLalchemy has this thing called events: https://docs.sqlalchemy.org/en/14/orm/session_events.html

Btw, thank you very much for great work, and best Async-ORM so far! 👍

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

No repository files, tests, or entry points are named. Start by reviewing the ORM's database-operation paths and comparing the requested scope with SQLAlchemy's session events. Done would require a defined hook API covering the intended database operations and metrics use cases, with tests documenting its behavior.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
database
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.