Don't you just want: cursor.execute("select * from T where C1 not in (%s,%s,%s)",params) The DBAPI should be fine with params being a python list of integers (as long as there are three of them).