summaryrefslogtreecommitdiff
path: root/mqtt_client/models.py
diff options
context:
space:
mode:
authorMatheus <matheus.guedes.mg.m@gmail.com>2025-11-04 20:31:30 -0300
committerMatheus <matheus.guedes.mg.m@gmail.com>2025-11-04 20:31:30 -0300
commite4e328259805df5d3365b78d96f16130ca822728 (patch)
treee971f230928aae008c79d4fbdd31c4ab71bd7a26 /mqtt_client/models.py
parentb49e9024a5bb595701b5300772b55b703b6b7856 (diff)
Update dbHEADmaster
Diffstat (limited to 'mqtt_client/models.py')
-rw-r--r--mqtt_client/models.py12
1 files changed, 6 insertions, 6 deletions
diff --git a/mqtt_client/models.py b/mqtt_client/models.py
index 98549bc..6b71fe1 100644
--- a/mqtt_client/models.py
+++ b/mqtt_client/models.py
@@ -1,7 +1,7 @@
from sqlalchemy import Column, Integer, String, Float, DateTime, ForeignKey, Boolean
from sqlalchemy.orm import relationship
from sqlalchemy.sql import func
-from database import Base
+from .database import Base
# ----------------------------
# Location
@@ -9,7 +9,7 @@ from database import Base
class Location(Base):
__tablename__ = "locations"
- id = Column(Integer, primary_key=True, index=True)
+ id = Column(Integer, primary_key=True, index=True, autoincrement=True)
street = Column(String(200), nullable=True, index=True)
avenue = Column(String(200), nullable=True, index=True)
zip_code = Column(String(20), nullable=True, index=True)
@@ -24,7 +24,7 @@ class Location(Base):
class Station(Base):
__tablename__ = "stations"
- id = Column(Integer, primary_key=True, index=True)
+ id = Column(Integer, primary_key=True, index=True, autoincrement=True)
name = Column(String(100), nullable=False, index=True)
location_id = Column(Integer, ForeignKey("locations.id"), nullable=True, index=True)
installation_date = Column(DateTime, server_default=func.now())
@@ -41,7 +41,7 @@ class Station(Base):
class SensorDevice(Base):
__tablename__ = "sensor_devices"
- id = Column(Integer, primary_key=True, index=True)
+ id = Column(Integer, primary_key=True, index=True, autoincrement=True)
name = Column(String(100), nullable=True, index=True)
installation_date = Column(DateTime, server_default=func.now())
station_id = Column(Integer, ForeignKey("stations.id"), nullable=True, index=True)
@@ -58,7 +58,7 @@ class SensorDevice(Base):
class Measure(Base):
__tablename__ = "measures"
- id = Column(Integer, primary_key=True, index=True)
+ id = Column(Integer, primary_key=True, index=True, autoincrement=True)
name = Column(String(50), nullable=True, index=True)
unit_code = Column(String(10), nullable=True)
@@ -72,7 +72,7 @@ class Measure(Base):
class Reading(Base):
__tablename__ = "readings"
- id = Column(Integer, primary_key=True, index=True)
+ id = Column(Integer, primary_key=True, index=True, autoincrement=True)
sensor_device_id = Column(Integer, ForeignKey("sensor_devices.id"), nullable=True, index=True)
measure_id = Column(Integer, ForeignKey("measures.id"), nullable=True, index=True)
value = Column(Float, nullable=True)