From 4f508bb5bb2bc5f706ebb5092652a0b718f20d36 Mon Sep 17 00:00:00 2001 From: Colin Goutte Date: Wed, 29 Sep 2021 10:30:58 +0200 Subject: [PATCH] Start models implementation --- papi/sqlapp/database.py | 1 + papi/sqlapp/models.py | 19 +++++++++++++++++++ 2 files changed, 20 insertions(+) diff --git a/papi/sqlapp/database.py b/papi/sqlapp/database.py index 53d97b6..9decfa0 100644 --- a/papi/sqlapp/database.py +++ b/papi/sqlapp/database.py @@ -2,6 +2,7 @@ from sqlalchemy import create_engine from sqlalchemy.ext.declarative import declarative_base from sqlalchemy.orm import sessionmaker + SQLALCHEMY_DATABASE_URL = "sqlite:///./sql_app.db" # SQLALCHEMY_DATABASE_URL = "postgresql://user:password@postgresserver/db" diff --git a/papi/sqlapp/models.py b/papi/sqlapp/models.py index e69de29..691e422 100644 --- a/papi/sqlapp/models.py +++ b/papi/sqlapp/models.py @@ -0,0 +1,19 @@ +from sqlalchemy import Boolean, Column, ForeignKey, Integer, String, JSON +from sqlalchemy.orm import relationship + +from .database import Base + + +class Sonde(Base): + __tablename__ = "sonde" + id = Column(Integer, primary_key=True, index=True) + nom = Column(String, index=True) + identifiant = Column(String, index=True, unique=True, nullable=False) + # mesures = relationship("Mesure") + + +class Mesure(Base): + __tablename__ == "mesure" + id = Column(Integer, primary_key=True, index=True) + # sonde_id = Column(Integer, Foreignkey("sonde.id") + content = Column(JSON, nullable=False)