cursor.execute(''' DELETE FROM repos WHERE url IN (SELECT url FROM repos_temp) ''') cursor.execute(''' INSERT INTO repos SELECT * FROM repos_temp ''')