Checking multiple user inputs to multiple fields in a sqlite3 database with python

21 Views Asked by At

I'm trying to compare the user's input to the values in the database. I want to then check if their input is in the database, if so it will print they have entered the valid details, if not it will print they have entered incorrect details.

def check_data_with_tbl(packet):  # Takes the packets sent by the client and compares them to the fields in the database
    sqlstring = """
    SELECT * FROM tblUserDetails WHERE Username = ? AND PasswordHash = ? 
                """

    if sqlstring is not None:
        print("Login Successful")
    else:
        print("Invalid Username or Password")

    values = (packet['username'], packet['password'])
    runsql(sqlstring, values)

At the moment it just prints login successful every time even if I enter incorrect details.

0

There are 0 best solutions below