I'm parsing some data to feed to a MySQL database, and would like to be able to pass in a list (a dictionary or a series of tuples) in the cursor.execute() or cursor.executemany() statement. Everything I tried initially raises errors. I'm sure it's a matter of correct formatting the list as a sequence... CODE: import sys, MySQLdb conn = MySQLdb.connect (host = "localhost", user = "user", psswd = "xxxx" db = "testdb") cursor = conn.cursor() infile = open(sys.argv[2], 'r') list_of_tuples = [] for line in infile: tuple = (line.split()[0], line.split()[1]) list_of_tuples.append(tuple) cursor.executemany("UPDATE LOW_PRIORITY sometable SET field1 = %s WHERE field2 = %s", (list_of_tuples) Looks like the elements of the list are being passed in as individual arguments rather than a formatted list. So, for the simplest case... I tried various versons of that cursor.execute including all variants with/without parentheses around %s &&|| list_of_ids: If I include one %s substitution for each element in the list, it works, but that raises the question of how to do it when you don't know the size of the list beforehand? So, for a 5 element list, this works: CODE: cursor.execute("SELECT field1, field2 FROM sometable WHERE field1 IN (%s, %s, %s, %s, %s)", list_of_ids) But when the list is generated by a previous select statement...? I dug through the docs a bit I pulled out executemany(), and so this seems to work: cursor.executemany("SELECT field1, field2 FROM sometable WHERE field1 IN (%s)", (list_of_ids))