You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
23 lines
639 B
23 lines
639 B
from sqlalchemy.ext.asyncio import async_sessionmaker, AsyncSession, create_async_engine
|
|
from sqlalchemy.orm import DeclarativeBase
|
|
|
|
class Model(DeclarativeBase):
|
|
pass
|
|
|
|
|
|
async_engine=create_async_engine(
|
|
url = "mssql+aioodbc://sa:159357"\
|
|
"@10.124.30.208:1433/test_db"\
|
|
"?driver=ODBC+Driver+17+for+SQL+Server",
|
|
connect_args={"check_same_thread": False}
|
|
)
|
|
|
|
async_session = async_sessionmaker(
|
|
async_engine,
|
|
autoflush=True,
|
|
autocommit=False,
|
|
expire_on_commit =False
|
|
)
|
|
# async def get_async_session() -> AsyncSession:
|
|
# async with async_session() as session:
|
|
# session.
|