File size: 697 Bytes
42cffde
d3530f3
42cffde
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
d3530f3
42cffde
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
# from env import config

# from sqlalchemy.ext.asyncio import create_async_engine, AsyncSession, async_sessionmaker
# print(config)
# database_url = f"mysql+aiomysql://{config['db']['user']}:{config['db']['password']}@{config['db']['host']}:{config['db']['port']}/{config['db']['database']}"
# engine = create_async_engine(
#     database_url,
#     pool_size=config['db']['pool_size'],
#     max_overflow=0,
#     pool_recycle=3600,
#     echo=False,
#     future=True,
# )
# SessionLocal = async_sessionmaker(
#     engine, 
#     expire_on_commit=False, 
#     class_=AsyncSession
# )

# def get_db():
#     db = SessionLocal()
#     try:
#         yield db
#     finally:
#         db.close()