update
This commit is contained in:
parent
b92f2ead8d
commit
c076be8439
Binary file not shown.
Binary file not shown.
29
create_db.py
29
create_db.py
|
@ -1,3 +1,32 @@
|
|||
import time
|
||||
|
||||
from api import add
|
||||
from db.base import Base, engine
|
||||
from db.models.lot_data_model import LOT_DATA
|
||||
from device import device_name
|
||||
|
||||
Base.metadata.create_all(bind=engine)
|
||||
try:
|
||||
data = {'ambient_temperature': -1,
|
||||
'ambient_humidity': -1,
|
||||
'carbon_dioxide': -1,
|
||||
'ambient_air_pressure': -1,
|
||||
'ambient_lighting': -1,
|
||||
'soil_moisture': -1,
|
||||
'soil_temperature': -1,
|
||||
'soil_conductivity': -1,
|
||||
'soil_PH': -1,
|
||||
'soil_potassium_phosphate_nitrogen': -1,
|
||||
'soil_potassium_phosphate_phosphorus': -1,
|
||||
'soil_potassium_phosphate_potassium': -1,
|
||||
'rainfall': -1,
|
||||
'wind_speed': -1,
|
||||
'wind_direction': -1,
|
||||
'create_time': int(time.time()),
|
||||
'device_name': 'test'
|
||||
}
|
||||
t2 = LOT_DATA(**data)
|
||||
add(t2)
|
||||
except Exception as e:
|
||||
print(e)
|
||||
pass
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
|
@ -5,6 +5,7 @@ from sqlalchemy.ext.declarative import declarative_base, DeclarativeMeta
|
|||
from sqlalchemy.orm import sessionmaker
|
||||
|
||||
import json
|
||||
|
||||
KB_ROOT_PATH = "/home/pi/"
|
||||
DB_ROOT_PATH = os.path.join(KB_ROOT_PATH, "lot_data.db")
|
||||
SQLALCHEMY_DATABASE_URI = f"sqlite:///{DB_ROOT_PATH}"
|
||||
|
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Loading…
Reference in New Issue