🔧 chore(repo): restructure project file hierarchy
- move project files out of fleetledger directory to root
- update .gitignore to reflect new .env path
📝 docs(README): add detailed project description
- provide an overview of FleetLedger's features and usage
- include setup instructions and security notes
This commit is contained in:
parent
f113a760af
commit
ea06f16407
27 changed files with 86 additions and 87 deletions
21
app/db.py
Normal file
21
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