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