Better integration of sqlite3 database

This commit is contained in:
GotthardG
2024-11-02 00:54:37 +01:00
parent 48cd233231
commit a01114a178
18 changed files with 835 additions and 582 deletions

View File

@@ -1,11 +1,13 @@
from fastapi import APIRouter
from typing import List, Optional
from app.data.data import proposals
from app.models import Proposal # Import the Address model
# app/routers/proposal.py
from fastapi import APIRouter, Depends
from sqlalchemy.orm import Session
from typing import List
from app.schemas import Proposal as ProposalSchema
from app.models import Proposal as ProposalModel
from app.dependencies import get_db
router = APIRouter()
@router.get("/", response_model=List[Proposal])
async def get_proposals():
return proposals
@router.get("/", response_model=List[ProposalSchema])
async def get_proposals(db: Session = Depends(get_db)):
return db.query(ProposalModel).all()