Fix db writing function

This commit is contained in:
2EEEB 2022-05-11 10:28:13 +02:00
parent 423fd1c982
commit 7da28f3485
Signed by: 2EEEB
GPG Key ID: 8F12BD6D9D435DB2

View File

@ -16,12 +16,15 @@ DB_TABLE = "envdata0" # name of the database table (mqtt topic is fitting here)
API_PORT = 8080
API_SECRET = "itsasecret" # set to same value as in the api
def write_db(sql, vals1): # function for writing to the database
def write_db(sql, vals=None): # function for writing to the database
dbconn = sql3db.connect(DB)
cursor = dbconn.cursor()
try:
cursor.execute(sql, vals)
if vals is not None:
cursor.execute(sql, vals)
else:
cursor.execute(sql)
except sql3db.Error as e:
print(e)
return False