mirror of
https://github.com/a-mayb3/Kanban_clone_backend.git
synced 2026-03-21 10:05:38 +01:00
29 lines
No EOL
647 B
Python
29 lines
No EOL
647 B
Python
from sqlalchemy import create_engine
|
|
from sqlalchemy.orm import sessionmaker
|
|
from sqlalchemy.ext.declarative import declarative_base
|
|
|
|
from pydantic import BaseModel, ConfigDict
|
|
|
|
from fastapi import Depends
|
|
from sqlalchemy.orm import Session
|
|
from typing import Annotated
|
|
|
|
|
|
|
|
URL_DATABASE = "sqlite:///./kanban_clone.db"
|
|
|
|
engine = create_engine(URL_DATABASE)
|
|
SessionLocal = sessionmaker(autocommit=False, autoflush=False, bind=engine)
|
|
|
|
Base = declarative_base()
|
|
|
|
Base.metadata.create_all(bind=engine)
|
|
|
|
def get_db():
|
|
db = SessionLocal()
|
|
try:
|
|
yield db
|
|
finally:
|
|
db.close()
|
|
|
|
db_dependency = Annotated[Session, Depends(get_db)] |