Python MySQL Connector database query with %s fails
问题 I have a basic program that is supposed to query a database that contains user information. I am trying to select the information for a specific user and print it out to the console. Here is my code: import mysql.connector funcon = mysql.connector.connect(user=\'root\', password=\'pass\', host=\'127.0.0.1\', database=\'fundata\') funcursor = funcon.cursor() query = (\"SELECT * FROM funtable WHERE userName=%s\") uName = \'user1\' funcursor.execute(query, uName) for (userName) in funcursor: