I'm trying to place a variable inside an SQLite query, I've read the documentation, I've read similar questions here and articles on Internet, but I keep getting the same two errors, when I hace this code:
import sqlite3
import sys
import time
user_id = (int(time.time()))
db_conn = sqlite3.connect('data.db')
db_curs = db_conn.cursor()
db_curs.execute('insert into Users values(?, "John Doe", "johndoe@yahoo.com", "52g5f2gf5gfg2f45f4f")', user_id)
db_curs.execute('select * from Users')
for registry in db_curs.fetchall():
print(registry)
db_conn.commit()
db_curs.close()
db_conn.close()
I get the following error in the line where I'm trying to insert the data:
ValueError: parameters are of unsupported type
If I convert the value of user_id to a string, like this:
user_id = (str(int(time.time())))
I get the following error:
sqlite3.ProgrammingError: Incorrect number of bindings supplied. The current statement uses 1, and there are 10 supplied.
Notice that the time since EPOCH is 10 numbers lenght, so I suppose there's the problem, obviously, but I don't know what it is.