I have my Python program linked with MYSQL database and in that database I have a table called 'user_data' where simply different user data are stored. I am trying to select a particular data from the database and display it or use it for some other purpose. The following code works likes a charm:
self.cursor = self.db.cursor()
self.cursor.execute("SELECT * from user_data WHERE Name = 'Anup'")
rows = self.cursor.fetchone()
print(rows)
However, this program isn't actually feasible for searching in the database. So when i try to modify my program to the one that is feasible, no output is available. Or simply the output is displayed as none. Following is the code that is displaying the error:
self.cursor = self.db.cursor()
name="Anup"
self.cursor.execute("SELECT * from user_data WHERE Name = '%s'",('name'))
rows = self.cursor.fetchone()
print(rows)