mirror of
https://github.com/d3vyce/fastapi-toolsets.git
synced 2026-03-01 17:00:48 +01:00
* docs: fix crud * docs: update README features * docs: add pagination/search example * docs: update zensical.toml * docs: cleanup * docs: update status to Stable + update description * docs: add example run commands
18 lines
632 B
Python
18 lines
632 B
Python
from typing import Annotated
|
|
|
|
from fastapi import Depends
|
|
from sqlalchemy.ext.asyncio import AsyncSession, async_sessionmaker, create_async_engine
|
|
|
|
from fastapi_toolsets.db import create_db_context, create_db_dependency
|
|
|
|
DATABASE_URL = "postgresql+asyncpg://postgres:postgres@localhost:5432/postgres"
|
|
|
|
engine = create_async_engine(url=DATABASE_URL, future=True)
|
|
async_session_maker = async_sessionmaker(bind=engine, expire_on_commit=False)
|
|
|
|
get_db = create_db_dependency(session_maker=async_session_maker)
|
|
get_db_context = create_db_context(session_maker=async_session_maker)
|
|
|
|
|
|
SessionDep = Annotated[AsyncSession, Depends(get_db)]
|