Source code for toardb.variables.models
# SPDX-FileCopyrightText: 2021 Forschungszentrum Jülich GmbH
# SPDX-License-Identifier: MIT
from sqlalchemy import Column, Integer, String, Sequence
from sqlalchemy.orm import relationship
from toardb.base import Base
VARIABLES_ID_SEQ = Sequence("variables_id_seq") # define sequence explicitly
[docs]class Variable(Base):
"""
Table "public.variables"
+------------------+------------------------+-----------+----------+---------------------------------------+
| Column | Type | Collation | Nullable | Default |
+==================+========================+===========+==========+=======================================+
| id | integer | | not null | nextval('variables_id_seq'::regclass) |
+------------------+------------------------+-----------+----------+---------------------------------------+
| name | character varying(32) | | not null | |
+------------------+------------------------+-----------+----------+---------------------------------------+
| longname | character varying(128) | | not null | |
+------------------+------------------------+-----------+----------+---------------------------------------+
| displayname | character varying(128) | | not null | |
+------------------+------------------------+-----------+----------+---------------------------------------+
| cf_standardname | character varying(128) | | not null | |
+------------------+------------------------+-----------+----------+---------------------------------------+
| units | character varying(64) | | not null | |
+------------------+------------------------+-----------+----------+---------------------------------------+
| chemical_formula | character varying(128) | | not null | |
+------------------+------------------------+-----------+----------+---------------------------------------+
Indexes:
"variables_pkey" PRIMARY KEY, btree (id)
"variables_name_key" UNIQUE CONSTRAINT, btree (name)
"variables_name_9bc98a13_like" btree (name varchar_pattern_ops)
Referenced by:
TABLE "timeseries" CONSTRAINT "timeseries_variable_id_dd9603f5_fk_variables_id" FOREIGN KEY (variable_id) REFERENCES variables(id) DEFERRABLE INITIALLY DEFERRED
"""
__tablename__ = "variables"
id = Column(
Integer,
VARIABLES_ID_SEQ,
primary_key=True,
server_default=VARIABLES_ID_SEQ.next_value(),
)
name = Column(String(32), nullable=False, unique=True)
longname = Column(String(128), nullable=False)
displayname = Column(String(128), nullable=False)
cf_standardname = Column(String(128), nullable=False)
units = Column(String(64), nullable=False)
chemical_formula = Column(String(128), nullable=False)
timeseries = relationship("Timeseries", back_populates="variable")