Source code for python_template_server.db.base_database_manager
"""SQLModel database module."""
import logging
from abc import ABC, abstractmethod
from sqlmodel import SQLModel, create_engine
from python_template_server.models import DatabaseConfig
logger = logging.getLogger(__name__)
[docs]
class BaseDatabaseManager(ABC):
"""Manager class for database operations.
Subclasses must implement the `db_url` property to provide the correct database URL.
The database manager must be configured using `configure()` after the server has loaded the configuration.
"""
[docs]
def __init__(self) -> None:
"""Initialize the database manager."""
logger.info("Ready to be configured...")
@property
@abstractmethod
def db_url(self) -> str:
"""Get the database URL using the `DatabaseConfig.db_url()` method."""