mirror of
https://github.com/a-mayb3/Kanban_clone_backend.git
synced 2026-03-21 10:05:38 +01:00
Started working on projects related endpoints
This commit is contained in:
parent
0b676688c2
commit
abd4d5e988
6 changed files with 93 additions and 63 deletions
19
database.py
19
database.py
|
|
@ -2,9 +2,28 @@ 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)]
|
||||
Loading…
Add table
Add a link
Reference in a new issue