45 lines
1.3 KiB
Python
45 lines
1.3 KiB
Python
|
from app import db
|
||
|
from subprocess import run
|
||
|
from database.constants import DB_USER, DB_PW, DB_NAME
|
||
|
|
||
|
|
||
|
class Glacier(db.Model):
|
||
|
uid = db.Column(db.String(5), primary_key=True)
|
||
|
country = db.Column(db.String(60))
|
||
|
name = db.Column(db.String(60))
|
||
|
annual_data = db.relationship("Annual_Data")
|
||
|
|
||
|
def __init__(self, uid, country, name):
|
||
|
self.uid = uid
|
||
|
self.country = country
|
||
|
self.name = name
|
||
|
|
||
|
|
||
|
class Annual_Data(db.Model):
|
||
|
__tablename__ = "annual_data"
|
||
|
year = db.Column(db.Integer, primary_key=True)
|
||
|
uid = db.Column(db.ForeignKey("glacier.uid"), primary_key=True)
|
||
|
surface = db.Column(db.Float)
|
||
|
length = db.Column(db.Float)
|
||
|
elevation = db.Column(db.Float)
|
||
|
|
||
|
def __init__(self, year, surface, length, elevation):
|
||
|
self.year = year
|
||
|
self.surface = surface
|
||
|
self.length = length
|
||
|
self.elevation = elevation
|
||
|
|
||
|
|
||
|
class User(db.Model):
|
||
|
uid = db.Column(db.Integer, primary_key=True)
|
||
|
registration_date = db.Column(
|
||
|
db.DateTime, nullable=False, server_default=db.func.now()
|
||
|
)
|
||
|
username = db.Column(db.String(20), nullable=False, unique=True)
|
||
|
password = db.Column(db.String(60))
|
||
|
|
||
|
def __init__(self, uid, username, password):
|
||
|
self.uid = uid
|
||
|
self.username = username
|
||
|
self.password = password
|