In a phython script I read a value from a hardware module. This value I want to insert in a mariadb
I convert the hardware value to a string.
wert_float="{:.1f}".format(sensor1)
wert = str(wert_float)
mycursor =mydb.cursor()
sql = "INSERT INTO werte (feuchtigkeit) VALUES (?)", (wert)
mycursor.execute(sql)
mydb.commit()
mycursor.close()
mydb.close()
I tried the statement with (%s) too, but at all tries I got the error:
Traceback (most recent call last):
File "./waterpi_sql.py", line 118, in <module>
mycursor.execute(sql)
TypeError: a bytes-like object is required, not 'tuple'
Can someone help me?