main
ZHANGXUXU\95193 4 months ago
parent 08119a416f
commit b69058a4bf

@ -463,15 +463,3 @@ class DevicesManange():
except Exception as e:
return print(e)
@classmethod
def update_or_insert_variable(self, variable_name, value):
# 这里假设有一个数据库模型类DeviceVariable用于操作变量数据
from utils.DBModels.DeviceModels import DeviceVariable
variable = DeviceVariable.get_by_name(variable_name)
if variable:
# 如果变量存在,则更新其值
variable.value = value
variable.save()
else:
# 如果变量不存在,则创建新记录
DeviceVariable.create(name=variable_name, value=value)

Loading…
Cancel
Save