release: bump version to 0.38.0
This commit is contained in:
@@ -1,3 +1,4 @@
|
||||
import logging
|
||||
from typing import AsyncGenerator
|
||||
|
||||
from sqlalchemy import text
|
||||
@@ -6,9 +7,20 @@ from sqlalchemy.orm import declarative_base
|
||||
|
||||
from app.core.config import settings
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
DB_POOL_CONFIG = {
|
||||
"pool_pre_ping": True,
|
||||
"pool_recycle": 1800,
|
||||
"pool_size": 10,
|
||||
"max_overflow": 20,
|
||||
"pool_timeout": 30,
|
||||
}
|
||||
|
||||
engine = create_async_engine(
|
||||
settings.DATABASE_URL,
|
||||
echo=settings.DEBUG if hasattr(settings, "DEBUG") else False,
|
||||
**DB_POOL_CONFIG,
|
||||
)
|
||||
|
||||
async_session_factory = async_sessionmaker(engine, class_=AsyncSession, expire_on_commit=False)
|
||||
@@ -97,6 +109,16 @@ async def init_db():
|
||||
import app.models.system_setting # noqa: F401
|
||||
import app.models.playground_session # noqa: F401
|
||||
import app.models.playground_message # noqa: F401
|
||||
import app.models.system_log # noqa: F401
|
||||
|
||||
logger.warning(
|
||||
"Database pool settings active: pre_ping=%s recycle=%ss size=%s overflow=%s timeout=%ss",
|
||||
DB_POOL_CONFIG["pool_pre_ping"],
|
||||
DB_POOL_CONFIG["pool_recycle"],
|
||||
DB_POOL_CONFIG["pool_size"],
|
||||
DB_POOL_CONFIG["max_overflow"],
|
||||
DB_POOL_CONFIG["pool_timeout"],
|
||||
)
|
||||
|
||||
async with engine.begin() as conn:
|
||||
await conn.run_sync(Base.metadata.create_all)
|
||||
|
||||
Reference in New Issue
Block a user