c.execute(
    'CREATE TABLE distro (id INTEGER PRIMARY KEY AUTOINCREMENT, name TEXT)')
for name in 'Ubuntu Fedora Puppy DSL SuSE'.split():
    c.execute('INSERT INTO distro (name) VALUES (?)', (name,))
desired_ids = ['1', '2', '5', '47']
result_set = c.execute('SELECT * FROM distro WHERE id IN (%s)' % ('?,' *
    len(desired_ids))[:-1], desired_ids)
for result in result_set:
    pass
Parameter substitution for a SQLite "IN" clause