new features
This commit is contained in:
@@ -5,6 +5,7 @@ from cpv3.modules.projects.models import Project
|
||||
from cpv3.modules.files.models import File
|
||||
from cpv3.modules.transcription.models import Transcription
|
||||
from cpv3.modules.users.models import User
|
||||
from cpv3.modules.notifications.models import Notification
|
||||
from cpv3.modules.webhooks.models import Webhook
|
||||
|
||||
__all__ = [
|
||||
@@ -17,5 +18,6 @@ __all__ = [
|
||||
"Transcription",
|
||||
"Job",
|
||||
"JobEvent",
|
||||
"Notification",
|
||||
"Webhook",
|
||||
]
|
||||
|
||||
+29
-5
@@ -2,19 +2,43 @@ from __future__ import annotations
|
||||
|
||||
from collections.abc import AsyncGenerator
|
||||
|
||||
from sqlalchemy.ext.asyncio import AsyncSession, async_sessionmaker, create_async_engine
|
||||
from sqlalchemy.ext.asyncio import (
|
||||
AsyncSession,
|
||||
async_sessionmaker,
|
||||
create_async_engine,
|
||||
)
|
||||
|
||||
from cpv3.infrastructure.settings import get_settings
|
||||
|
||||
|
||||
_settings = get_settings()
|
||||
_database_url = _settings.get_database_url()
|
||||
|
||||
_engine_kwargs: dict[str, bool | int] = {
|
||||
"echo": _settings.debug,
|
||||
"pool_pre_ping": True,
|
||||
}
|
||||
|
||||
if not _database_url.startswith("sqlite"):
|
||||
_engine_kwargs.update(
|
||||
{
|
||||
"pool_size": _settings.db_pool_size,
|
||||
"max_overflow": _settings.db_max_overflow,
|
||||
"pool_timeout": _settings.db_pool_timeout,
|
||||
"pool_recycle": _settings.db_pool_recycle_seconds,
|
||||
}
|
||||
)
|
||||
|
||||
_engine = create_async_engine(
|
||||
_settings.get_database_url(),
|
||||
echo=_settings.debug,
|
||||
pool_pre_ping=True,
|
||||
_database_url,
|
||||
**_engine_kwargs,
|
||||
)
|
||||
|
||||
SessionLocal = async_sessionmaker(bind=_engine, class_=AsyncSession, expire_on_commit=False)
|
||||
SessionLocal = async_sessionmaker(
|
||||
bind=_engine,
|
||||
class_=AsyncSession,
|
||||
expire_on_commit=False,
|
||||
)
|
||||
|
||||
|
||||
async def get_db() -> AsyncGenerator[AsyncSession, None]:
|
||||
|
||||
Reference in New Issue
Block a user