I want to copy all values that has an ID that is contained in a python list into a new table in SQLite like this:
cur.execute("INSERT INTO newtable SELECT * FROM oldtable where userid IN " + userids)
Userids is a list that comes from a file:
userids = [line.strip() for line in open('inputfile.txt')]
But I get the following error: TypeError: cannot concatenate 'str' and 'list' objects
And I have the growing suspicion that this list with about 15000 elements would be too long for the query as well(?). How would I do this without querying once for each id in the list?
Aucun commentaire:
Enregistrer un commentaire