Files
psqlmapper/database.py
2025-07-31 08:21:55 +10:00

30 lines
720 B
Python

from typing import TypeVar
import logging
from collections import namedtuple
from .registry import Registry
from .connector import Connector
logger = logging.getLogger(__name__)
T = TypeVar('T', bound=Registry)
class Database(Connector):
# cursor_factory = AsyncLoggingCursor
def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
self.registries: dict[str, Registry] = {}
def load_registry(self, registry: T) -> T:
logger.debug(
f"Loading and binding registry '{registry.name}'.",
extra={'action': f"Reg {registry.name}"}
)
registry.bind(self)
self.registries[registry.name] = registry
return registry