0

I am trying to create a Login Window (tkinter), and I am trying to get the inputs in a SQL DataBase Table.

I am getting an error at this code, I am also trying to see wether the inputs are already in the table or no:

def check (username, password):
    cursor.execute("SELECT COUNT(*) FROM Users WHERE username = :username and password = :password", username=username, password=password)

This is the error: enter image description here

This is how I am calling the function:

def checkLogin():
    name = name_var.get()
    password = passw_var.get()
    connectiontosql.check(name, password)

Note: connectiontosql is another module, created by me.

I have little to no knowledge in SQL, google didn't help too much, sorry if it's dead easy.

cybiroot
  • 1
  • 2
  • I *think* `pyodbc` might be expecting parameter placeholders like `?` rather than `:username` at least looking at this example https://github.com/mkleehammer/pyodbc/wiki/Getting-started#parameters – JonSG Mar 15 '22 at 17:25
  • Does this answer your question? [Does pyodbc support any form of named parameters?](https://stackoverflow.com/questions/32748982/does-pyodbc-support-any-form-of-named-parameters) – JonSG Mar 15 '22 at 17:25
  • note quite :D https://imgur.com/a/pMV9xZC – cybiroot Mar 15 '22 at 17:34
  • Try: `"SELECT COUNT(*) FROM Users WHERE username = ? and password = ?", [username, password])` using square brackets rather than round – JonSG Mar 15 '22 at 17:36

0 Answers0