1
votes
import sqlite3

db = sqlite3.connect('login.db')
c = db.cursor()
c.execute("CREATE TABLE IF NOT EXISTS users (email TEXT, password TEXT)")

def register():
    global user
    global passw
    print('REGISTER')
    user = (str(input('User: ')))
    passw = (str(input('Pass: ')))
    c.execute("INSERT INTO users VALUES ('"+user+"', '"+passw+"')")
    db.commit()
    print('REGISTRADO COM SUCESSO!')
    login()

def login():
    global luser
    global lpassw
    luser = (str(input('User: ')))
    lpassw = (str(input('Pass: ')))
    find_users = c.execute("SELECT * from users WHERE email = ? AND password = ?")
    c.execute(find_users, [(luser), (lpassw)])
    r = c.fetchall()
    if r:
        print('LOGADO!')
    else:
        login()

register()

I'm doing a login and register system in python + sqlite3.

every time I run this error:

File "d:\darkzinmaker\py\files\login.py", line 23, in login find_users = c.execute("SELECT * from users WHERE email = ? AND password = ?")

sqlite3. ProgrammingError: Incorrect number of bindings supplied. The current statement uses 2, and there are 0 supplied.

Could someone help me ;(

1

1 Answers

0
votes

Try this.

def login():
    global luser
    global lpassw
    luser = (str(input('User: ')))
    lpassw = (str(input('Pass: ')))

    # removed the c.execute 
    find_users = "SELECT * from users WHERE email = ? AND password = ?")
    c.execute(find_users, [(luser), (lpassw)])

    r = c.fetchall()
    if r:
        print('LOGADO!')
    else:
        login()