Boilerplate FastAPI & Dockerfile + NGINX
This commit is contained in:
0
app/db/__init__.py
Normal file
0
app/db/__init__.py
Normal file
5
app/db/base.py
Normal file
5
app/db/base.py
Normal file
@@ -0,0 +1,5 @@
|
||||
from app.models.user import User
|
||||
from app.models.server import Server
|
||||
from app.models.sshkey import SSHKey
|
||||
from app.models.access_request import AccessRequest
|
||||
from app.models.audit import AuditEvent
|
9
app/db/session.py
Normal file
9
app/db/session.py
Normal file
@@ -0,0 +1,9 @@
|
||||
from sqlalchemy.ext.asyncio import create_async_engine, async_sessionmaker, AsyncSession
|
||||
from app.core.config import settings
|
||||
|
||||
engine = create_async_engine(settings.POSTGRES_DSN, echo=False, future=True)
|
||||
AsyncSessionLocal = async_sessionmaker(engine, expire_on_commit=False, class_=AsyncSession)
|
||||
|
||||
async def get_session() -> AsyncSession:
|
||||
async with AsyncSessionLocal() as session:
|
||||
yield session
|
Reference in New Issue
Block a user