'Insert python time to column "TIME" in my sql database

I want to calculate elapsed time in python and insert it to my table database with column type "time" in format "seconds.miliseconds" like "3.123" or 120.889. So I wrote:

start_time = time.time()
time.sleep(5)
elapsed_time = time.time() - start_time

My SQL query in diffrent file

query = "INSERT INTO server_events(id, connection_time) VALUES (NULL, %s)"
        self.cursor.execute(query, (elapsed_time, ))
        self.connection.commit()

But i got error like below:

raise errors.ProgrammingError(
mysql.connector.errors.ProgrammingError: Not all parameters were used in the SQL statement

I thing that the main problem is type of elapsced_time variable (it's float). How could I fix that error?



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source