-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdatabase_controller.py
More file actions
23 lines (16 loc) · 849 Bytes
/
database_controller.py
File metadata and controls
23 lines (16 loc) · 849 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
from flask_login import UserMixin
from flask_sqlalchemy import SQLAlchemy
db = SQLAlchemy()
class User(UserMixin, db.Model):
id = db.Column(db.String(50), primary_key=True, unique=True)
username = db.Column(db.String(50), unique=True)
password = db.Column(db.String(80))
def __str__(self):
return "[ USER : id: {0}, username: {1}, password: {2} ]".format(self.id, self.username, self.password)
class Timeseries(UserMixin, db.Model):
id = db.Column(db.String(50), unique=True, primary_key=True)
sensor_id = db.Column(db.String(50))
timestamp = db.Column(db.DateTime) # datetime.datetime()
sensor_data = db.Column(db.Float)
def __str__(self):
return "[ TIMESERIES : id: {0}, sensor_id: {1}, timestamp: {2}, sensor_data: {3}]".format(self.id, self.sensor_id, self.timestamp, self.sensor_data)