Psycopg2, Postgresql, Python: Fastest way to bulk-insert

前端 未结 8 1381
轻奢々
轻奢々 2020-11-30 22:48

I\'m looking for the most efficient way to bulk-insert some millions of tuples into a database. I\'m using Python, PostgreSQL and psycopg2.

I have created a long lis

8条回答
  •  情歌与酒
    2020-11-30 23:10

    in my experience executemany is not any faster than running many inserts yourself, the fastest way is to format a single INSERT with many values yourself, maybe in the future executemany will improve but for now it is quite slow

    i subclass a list and overload the append method ,so when a the list reaches a certain size i format the INSERT to run it

提交回复
热议问题