-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathdatabase.py
More file actions
executable file
·46 lines (37 loc) · 1.55 KB
/
Copy pathdatabase.py
File metadata and controls
executable file
·46 lines (37 loc) · 1.55 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
#!/usr/bin/env python3
from enum import Enum
from sqlalchemy import Column, DateTime, Float, Integer, String
from sqlalchemy.sql import func
from sramplatform.storage import DBManager, DBParameters, TableBase
class Sample(TableBase):
__tablename__ = "CRPs"
# Internal id of the sample.
id = Column(Integer, primary_key=True)
# Type of device connected in the chain.
board_type = Column(String, nullable=False)
# Universal ID of the device.
uid = Column(String, nullable=False)
# Position In Chain of the device.
pic = Column(Integer, nullable=False)
# Region of SRAM. Formated as 0x00000000
address = Column(String, nullable=False)
# Comma separated list of values from the memory.
data = Column(String, nullable=False)
# Timestamp when the sample was gathered.
created_at = Column(DateTime, server_default=func.now(), nullable=False)
class Sensor(TableBase):
__tablename__ = "Sensors"
# Internal id of the sensor data.
id = Column(Integer, primary_key=True)
# Type of device connected in the chain.
board_type = Column(String, nullable=False)
# Universal ID of the device.
uid = Column(String, nullable=False)
# Temperature value in degrees celsius.
temperature = Column(Float, nullable=False)
# Internal VDD in volts.
voltage = Column(Float, nullable=False)
# Timestamp when the sensor data was obtained.
created_at = Column(DateTime, server_default=func.now(), nullable=False)
params = DBParameters("user", "password", "database")
dbmanager = DBManager(params)