add observation class for importing observations
This commit is contained in:
parent
1dafc5824c
commit
7dd739b04e
5 changed files with 75 additions and 28 deletions
|
|
@ -10,16 +10,52 @@ from datetime import datetime
|
|||
|
||||
# import os
|
||||
from sqlalchemy import (Column, Integer,
|
||||
String, DateTime)
|
||||
String, DateTime, ForeignKey, Numeric)
|
||||
from sqlalchemy.ext.declarative import declarative_base
|
||||
from sqlalchemy.orm import session
|
||||
from marshmallow import Schema
|
||||
from db.pg_models import create_pg_session
|
||||
from sqlalchemy.orm import session, relationship
|
||||
#from marshmallow import Schema
|
||||
from marshmallow_sqlalchemy import SQLAlchemyAutoSchema
|
||||
from db.pg_models import create_pg_session
|
||||
|
||||
|
||||
Base = declarative_base()
|
||||
|
||||
|
||||
class Observation(Base):
|
||||
""" observation class """
|
||||
__tablename__ = 'observation'
|
||||
__table_args__ = {"schema": "gba"}
|
||||
|
||||
id = Column('observation_id', Integer, primary_key=True)
|
||||
name = Column('name', String)
|
||||
value_type = Column('value_type', String)
|
||||
# pitch = Column('PITCH', String)
|
||||
# roll = Column('ROLL', String)
|
||||
sampling_time_start = Column('sampling_time_start', DateTime)
|
||||
sampling_time_end = Column('sampling_time_end', DateTime)
|
||||
result_time = Column('result_time', DateTime)
|
||||
sta_identifier = Column('sta_identifier', String)
|
||||
value_quantity = Column('value_quantity', Numeric(20, 10), nullable=False)
|
||||
|
||||
# fk_dataset_id = Column('fk_dataset_id', Integer,
|
||||
# ForeignKey('gba.dataset.dataset_id'))
|
||||
# dataset = relationship("Dataset", lazy="joined",
|
||||
# foreign_keys=[fk_dataset_id])
|
||||
fk_dataset_id = Column(Integer, ForeignKey(
|
||||
'gba.dataset.dataset_id'), nullable=False)
|
||||
# dataset = relationship("Dataset", back_populates="observations")
|
||||
|
||||
class ObservationSchema(SQLAlchemyAutoSchema):
|
||||
""" Platform class """
|
||||
class Meta:
|
||||
""" Platform class """
|
||||
model = Observation
|
||||
include_relationships = True
|
||||
load_instance = True
|
||||
#pg_session: session = create_pg_session()
|
||||
sqla_session: session = create_pg_session()
|
||||
|
||||
|
||||
class Person(Base):
|
||||
""" Platform class """
|
||||
__tablename__ = 'accounts'
|
||||
|
|
@ -30,9 +66,10 @@ class Person(Base):
|
|||
login = Column(String(255))
|
||||
timestamp = Column('updated_at', DateTime, default=datetime.utcnow,
|
||||
onupdate=datetime.utcnow)
|
||||
|
||||
def __repr__(self):
|
||||
return "<User(name='%s', lastname='%s')>" % (
|
||||
self.login, self.lname)
|
||||
self.login, self.lname)
|
||||
|
||||
|
||||
class PersonSchema(SQLAlchemyAutoSchema):
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue