Python Core



Admission Enquiry Form


Prepared statement or parameterized query

#using prepared statment or parameterized query
import mysql.connector as sql
con=sql.connect(host="localhost",database="compuhelp",user="root",password="")
print("connection ok")
mycur=con.cursor(prepared=True)
mylist=list()
myfee=int(input("Enter fee :"))
mylist.append(myfee)
mycur.execute("select * from student where fee=%s",mylist)
for row in mycur:
print(row[0],row[1],row[2])