- Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdatabase.py
More file actions
Latest commit
18 lines (12 loc) · 442 Bytes
/
Copy pathdatabase.py
File metadata and controls
18 lines (12 loc) · 442 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
fromsqlalchemy.ext.asyncioimportAsyncSession, create_async_engine, async_sessionmaker
fromsqlalchemy.ormimportDeclarativeBase
fromconfigimportsettings
engine=create_async_engine(
settings.database_url
)
AsyncSessionLocal=async_sessionmaker(engine, class_=AsyncSession, expire_on_commit=False)
classBase(DeclarativeBase):
pass
asyncdefget_db():
asyncwithAsyncSessionLocal() assession:
yieldsession