I am trying to select an array of values from my MySQL without using a for loop. The for loop takes to long and I want to grab all of the values at once. I do not know what is wrong with my arguments and I am having a hard time interpreting what the error message I receive means.
zipcode = ["37204", "60964", "60068"]
connection = MySQLdb.connect(host="localhost", user="root", passwd="password", db="database", cursorclass=MySQLdb.cursors.SSCursor)
cursor = connection.cursor()
query = "SELECT fips FROM us WHERE zip = %s"
cursor.executemany(query,zipcode)
results = cursor.fetchall()
The error looks like this:
query = query % tuple([db.literal(item) for item in args])
TypeError: not all arguments converted during string formatting
Any help is appreciated.