Using Python's built-in defaultdict we can easily define a tree data structure:
def tree(): return defaultdict(tree)That's it!
| import pytest | |
| from typing import Any, List, Tuple | |
| from sqlalchemy.orm import Session | |
| from sqlalchemy import event | |
| class QueriesCounter: | |
| def __init__(self, db: Session): | |
| self._count: int = 0 | |
| self._active: bool = False |
Using Python's built-in defaultdict we can easily define a tree data structure:
def tree(): return defaultdict(tree)That's it!