✨ feat(fleetledger): add initial implementation of FleetLedger app
- introduce Dockerfile for Python environment setup - create FastAPI app with authentication and user management - implement server management features with CRUD operations - add PWA support with service worker and manifest - set up initial templates for UI components 📝 docs(fleetledger): add README for FleetLedger application - describe app features and functionalities - provide security notes and quick start guide 📦 build(fleetledger): configure Docker and docker-compose setup - define Dockerfile for application container - create docker-compose.yml for service orchestration - specify environment variables and volumes for persistence
This commit is contained in:
parent
0151bf19f6
commit
b9cfefa3a9
24 changed files with 2598 additions and 0 deletions
21
fleetledger/app/db.py
Normal file
21
fleetledger/app/db.py
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
from sqlmodel import SQLModel, create_engine, Session
|
||||
import os
|
||||
|
||||
# SQLite database path, mapped to a Docker volume for persistence
|
||||
DB_PATH = os.getenv("DATABASE_PATH", "/data/fleetledger.db")
|
||||
|
||||
engine = create_engine(
|
||||
f"sqlite:///{DB_PATH}",
|
||||
connect_args={"check_same_thread": False},
|
||||
)
|
||||
|
||||
|
||||
def init_db() -> None:
|
||||
"""Create all tables if they do not exist yet."""
|
||||
SQLModel.metadata.create_all(engine)
|
||||
|
||||
|
||||
def get_session():
|
||||
"""FastAPI dependency that yields a SQLModel session."""
|
||||
with Session(engine) as session:
|
||||
yield session
|
||||
Loading…
Add table
Add a link
Reference in a new issue