Hi all, I'm very new to Python (7 days and counting) and seem to be having problems with passing in variables into my SELECT query.
The intention is to use the value selected from a combo box as the condition in the WHERE clause.
Please note that I'm using VS Code 1.5.8.2, MySQL 8.0.20, Python3
I have tried the ? method and it didn't work, I then tried the %s but nothing was returned. Below is the snippet
in question (sincere apologies for the dire quality of my coding):
#note that mycmb holds the value selected from the combo box
sql = "SELECT * FROM tbl_colours WHERE pc_name = %s"
mycmb = (cmb1.get(), )
mycursor = mydb.cursor();
mycursor.execute(sql, mycmb)
myresult = mycursor.fetchall();
I don't have a clue what the problem is and have tried all solutions found on the web.
Any help would be appreciated.
The intention is to use the value selected from a combo box as the condition in the WHERE clause.
Please note that I'm using VS Code 1.5.8.2, MySQL 8.0.20, Python3
I have tried the ? method and it didn't work, I then tried the %s but nothing was returned. Below is the snippet
in question (sincere apologies for the dire quality of my coding):
#note that mycmb holds the value selected from the combo box
sql = "SELECT * FROM tbl_colours WHERE pc_name = %s"
mycmb = (cmb1.get(), )
mycursor = mydb.cursor();
mycursor.execute(sql, mycmb)
myresult = mycursor.fetchall();
I don't have a clue what the problem is and have tried all solutions found on the web.
Any help would be appreciated.