From 7da28f3485bea87db26b1877dcc73959c3246708 Mon Sep 17 00:00:00 2001 From: 2EEEB <192235@vutbr.cz> Date: Wed, 11 May 2022 10:28:13 +0200 Subject: [PATCH] Fix db writing function --- inenvmon/inenvmon_collector.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/inenvmon/inenvmon_collector.py b/inenvmon/inenvmon_collector.py index 4cc2329..df3b0a5 100755 --- a/inenvmon/inenvmon_collector.py +++ b/inenvmon/inenvmon_collector.py @@ -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