lot_manager/create_db.py

32 lines
934 B
Python
Executable File

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