I am trying to write some data to a database but I get the error:
must be real number, not str
After a keyboard interrupt (strg + c)
Traceback (most recent call last):
  File "mqtt_logger.py", line 61, in <module>
    time.sleep(1)                # Sleep for a second
KeyboardInterrupt
The function is:
Temperature = BME["Temperature"] #Temperature String from a MQTT Device
Temperature_float = float(Temperature)
print(Temperature_float)
db = initDatabase() #db is a initialised database
cursorObject = db.cursor()
try:
    sqlCommand   = """INSERT INTO tbl_data_jakob (temperature) VALUES (%f)"""
    cursorObject.execute(sqlCommand,Temperature_float)
    db.commit()
    print("Inserted (Hopefully)")
except Exception as e:
    db.rollback()
    print(e)
db.close()
The main Programm is:
ourClient = mqtt.Client("MQTT_Client")        # Create a MQTT client 
object
ourClient.connect("IP", 1883)    # Connect to the test MQTT broker
ourClient.subscribe("tele/Sensor")            # Subscribe to the topic 
db = initDatabase()
ourClient.on_message = messageFunction        # Attach the messageFunction to subscription
ourClient.loop_start()                # Start the MQTT client
# Main program loop
while(1):
    time.sleep(1)                # Sleep for a second
