Python Pandas - Using to_sql to write large data frames in chunks

后端 未结 2 367
刺人心
刺人心 2020-12-06 04:55

I\'m using Pandas\' to_sql function to write to MySQL, which is timing out due to large frame size (1M rows, 20 columns).

http://pandas.pydata.org/panda

2条回答
  •  萌比男神i
    2020-12-06 05:57

    Update: this functionality has been merged in pandas master and will be released in 0.15 (probably end of september), thanks to @artemyk! See https://github.com/pydata/pandas/pull/8062

    So starting from 0.15, you can specify the chunksize argument and e.g. simply do:

    df.to_sql('table', engine, chunksize=20000)
    

提交回复
热议问题