Fix db writing function
This commit is contained in:
parent
423fd1c982
commit
7da28f3485
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue