25 lines
788 B
Python
25 lines
788 B
Python
from fastapi import FastAPI, Depends
|
|
from sqlalchemy.orm import Session
|
|
from app import crud, models, schemas
|
|
from app.database import engine, get_db
|
|
|
|
# Create tables if not exist
|
|
models.Base.metadata.create_all(bind=engine)
|
|
|
|
app = FastAPI(title="Data Lab API")
|
|
|
|
@app.get("/")
|
|
def root():
|
|
return {"message": "Welcome to Data Lab API"}
|
|
|
|
@app.get("/customers", response_model=list[schemas.Customer])
|
|
def get_customers(db: Session = Depends(get_db)):
|
|
return crud.get_customers(db)
|
|
|
|
@app.get("/accounts", response_model=list[schemas.Account])
|
|
def get_accounts(db: Session = Depends(get_db)):
|
|
return crud.get_accounts(db)
|
|
|
|
@app.get("/transactions", response_model=list[schemas.Transaction])
|
|
def get_transactions(db: Session = Depends(get_db)):
|
|
return crud.get_transactions(db)
|