This commit is contained in:
xyj 2023-12-09 15:53:56 +08:00
parent b92f2ead8d
commit c076be8439
12 changed files with 32 additions and 2 deletions

Binary file not shown.

Binary file not shown.

View File

@ -1,3 +1,32 @@
from db.base import Base, engine import time
Base.metadata.create_all(bind=engine) 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.

View File

@ -5,6 +5,7 @@ from sqlalchemy.ext.declarative import declarative_base, DeclarativeMeta
from sqlalchemy.orm import sessionmaker from sqlalchemy.orm import sessionmaker
import json import json
KB_ROOT_PATH = "/home/pi/" KB_ROOT_PATH = "/home/pi/"
DB_ROOT_PATH = os.path.join(KB_ROOT_PATH, "lot_data.db") DB_ROOT_PATH = os.path.join(KB_ROOT_PATH, "lot_data.db")
SQLALCHEMY_DATABASE_URI = f"sqlite:///{DB_ROOT_PATH}" SQLALCHEMY_DATABASE_URI = f"sqlite:///{DB_ROOT_PATH}"

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.