Implemented FastAPI backend with SQLite database for tracking seismograph fleet status: - database.py: SQLAlchemy setup with SQLite - models.py: Emitter model with id, unit_type, last_seen, last_file, status, notes - routes.py: POST /emitters/report and GET /fleet/status endpoints - main.py: FastAPI app initialization with CORS support - requirements.txt: Dependencies (FastAPI, SQLAlchemy, uvicorn)
19 lines
656 B
Python
19 lines
656 B
Python
from sqlalchemy import Column, String, DateTime
|
|
from datetime import datetime
|
|
from database import Base
|
|
|
|
|
|
class Emitter(Base):
|
|
"""Emitter model representing a seismograph unit in the fleet"""
|
|
__tablename__ = "emitters"
|
|
|
|
id = Column(String, primary_key=True, index=True)
|
|
unit_type = Column(String, nullable=False)
|
|
last_seen = Column(DateTime, default=datetime.utcnow)
|
|
last_file = Column(String, nullable=False)
|
|
status = Column(String, nullable=False) # OK, Pending, Missing
|
|
notes = Column(String, nullable=True)
|
|
|
|
def __repr__(self):
|
|
return f"<Emitter(id={self.id}, type={self.unit_type}, status={self.status})>"
|