python - insert ignore pandas dataframe into mysql -
i want "insert ignore" entire pandas dataframe mysql. there way without looping on rows?
in dataframe.to_sql see option if_exists 'append' still continue on duplicate unique keys?
consider using temp table (with exact structure of final table) replaced pandas run insert ignore in cursor call:
dataframe.to_sql('mytemptable', con, if_exists ='replace') cur = con.cursor() cur.execute("insert ignore myfinaltable select * mytemptable") con.commit()
Comments
Post a Comment