25 lines
674 B
Python
25 lines
674 B
Python
from sqlalchemy.ext.asyncio import create_async_engine, AsyncEngine
|
|
from sqlalchemy import create_engine, Engine
|
|
from app.core.config import settings
|
|
|
|
# =========================
|
|
# SYNCHRONOUS ENGINE
|
|
# =========================
|
|
# Pour opérations sync classiques
|
|
engine: Engine = create_engine(
|
|
settings.database_url.replace('<driver>', "pymysql"),
|
|
echo=settings.DEBUG,
|
|
future=True
|
|
)
|
|
|
|
# =========================
|
|
# ASYNCHRONOUS ENGINE
|
|
# =========================
|
|
# Pour opérations async avec async SQLAlchemy
|
|
async_engine: AsyncEngine = create_async_engine(
|
|
settings.database_url.replace('<driver>', "aiomysql"),
|
|
echo=settings.DEBUG,
|
|
future=True
|
|
)
|
|
|