35 lines
1.1 KiB
Python
35 lines
1.1 KiB
Python
from typing import AsyncGenerator
|
|
|
|
from sqlalchemy import create_engine, select, MetaData
|
|
# from sqlalchemy.ext.asyncio import AsyncSession, async_sessionmaker, create_async_engine
|
|
from sqlalchemy.orm import sessionmaker, Session, DeclarativeBase
|
|
from sqlalchemy.ext.declarative import declarative_base
|
|
|
|
from fastapi import Depends
|
|
# from fastapi_users.db import SQLAlchemyBaseUserTableUUID, SQLAlchemyUserDatabase
|
|
|
|
|
|
SQLALCHEMY_DATABASE_URL = "sqlite:///./sql_app.db"
|
|
|
|
engine = create_engine(
|
|
SQLALCHEMY_DATABASE_URL, connect_args={"check_same_thread": False}
|
|
)
|
|
|
|
SessionLocal = sessionmaker(bind=engine, autoflush=True, autocommit=False)
|
|
|
|
database = SessionLocal()
|
|
Base = declarative_base()
|
|
|
|
|
|
# # add your model's MetaData object here
|
|
# # for 'autogenerate' support
|
|
# # in your application's model:
|
|
|
|
# class Base(DeclarativeBase):
|
|
# metadata = MetaData(naming_convention={
|
|
# "ix": "ix_%(column_0_label)s",
|
|
# "uq": "uq_%(table_name)s_%(column_0_name)s",
|
|
# "ck": "ck_%(table_name)s_`%(constraint_name)s`",
|
|
# "fk": "fk_%(table_name)s_%(column_0_name)s_%(referred_table_name)s",
|
|
# "pk": "pk_%(table_name)s"
|
|
# }) |