N
N
NOblo2020-06-14 15:29:50
Python
NOblo, 2020-06-14 15:29:50

Sqlite3 3 error, what's the error out of the blue?

Here is the code:

import sqlite3 
db = sqlite3.connect('server.sqlite') 
sql = db.cursor() 
sql.execute("""CREATE TABLE IF NOT EXISTS _Users_ (name TEXT)""") 
db.commit() 
UserName = input("Ваш ник?: ") 
sql.execute("SELECT name FROM _Users_") 
 
sql.execute("INSERT INTO _Users_ VALUES (?)", (UserName)) 
 
db.commit() 
for i in sql.execute("SELECT * FROM _Users_"): 
 print("Вот все ники:" + i)

Here is the error:
sql.execute("INSERT INTO _Users_ VALUES (?)", (UserName))
sqlite3.ProgrammingError: Incorrect number of bindings supplied. The current statement uses 1, and there are 8 supplied.

You can write 1 letter in the input, and everything will be fine, without an error, but if there are 2 or more letters, then here is the error. How to make that words can be written to the database?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
ScriptKiddo, 2020-06-14
@NOblo

sql.execute("INSERT INTO _Users_ VALUES (?)", ((UserName,)))

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question