How can I check if a record exists where the username of the record has the value of the variable usernameentryentry?
I want to create an if statement so that if there is already a record with the username of the same value as the usernameentryentry variable then the user is told that the username is taken already.
How can I do this?
import sqlite3
with sqlite3.connect("userdatabase.db") as db:
cursor = db.cursor()
usernameentryentry = "username1"
cursor.execute('''
CREATE TABLE IF NOT EXISTS users (
userID INTEGER PRIMARY KEY,
username VARCHAR(20) NOT NULL,
password VARCHAR(20) NOT NULL) ;
''')
#variable defined below for use in the if statement:
#variable = true if there isnt a record with the username "username1" and
#false if there is a record with the username "username1"