-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdatabase.py
More file actions
28 lines (20 loc) · 713 Bytes
/
Copy pathdatabase.py
File metadata and controls
28 lines (20 loc) · 713 Bytes
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
26
27
28
# Database Configuration
# Async SQLAlchemy database setup for authorization and user data storage
# Used by authorization module to store user credentials and session data
from sqlalchemy.ext.asyncio import AsyncSession, async_sessionmaker, create_async_engine
from sqlalchemy.orm import DeclarativeBase
SQLALCHEMY_DATABASE_URL = "sqlite+aiosqlite:///./blog.db"
engine = create_async_engine(
SQLALCHEMY_DATABASE_URL,
connect_args={"check_same_thread": False},
)
AsyncSessionLocal = async_sessionmaker(
engine,
class_=AsyncSession,
expire_on_commit=False,
)
class Base(DeclarativeBase):
pass
async def get_db():
async with AsyncSessionLocal() as session:
yield session