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

20
backend/app/crud.py Normal file
View File

@ -0,0 +1,20 @@
from sqlalchemy.orm import Session, joinedload
def get_shipments(db: Session):
from app.models import Shipment
return db.query(Shipment).options(
joinedload(Shipment.contact_person),
joinedload(Shipment.return_address),
joinedload(Shipment.proposal),
joinedload(Shipment.dewars)
).all()
def get_shipment_by_id(db: Session, shipment_id: str):
from app.models import Shipment
shipment = db.query(Shipment).options(
joinedload(Shipment.contact_person),
joinedload(Shipment.return_address),
joinedload(Shipment.proposal),
joinedload(Shipment.dewars)
).filter(Shipment.shipment_id == shipment_id).first()
return shipment