T
T
TheMergus2019-11-22 21:09:59
Python
TheMergus, 2019-11-22 21:09:59

python sqlite3 error, why?

I add a new row to the database like this:

connection = sqlite3.connect('database.sqlite')
q = connection.cursor()
q.execute("INSERT INTO users (id,name,deposit,balans,cbc_balans,cbc_bal,ref,ref_colvo,ref_colvo2,ref_colvo3,ref_earn,aktiv) VALUES ('%s', '%s', '%s', '%s', '%s','%s', '%s' '%s', '%s', '%s', '%s', '%s')"%(userid,username,'0','0','0','0',ref_url[7:],'0','0','0','0','0'))
connection.commit()

I get an error: sqlite3.OperationalError: near "'0'": syntax error
I understand that the error is due to these zeros, but I really need them, how to fix the error?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Andrey Burov, 2019-11-22
@TheMergus

'%s' '%s',

Missed a comma.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question