【发布时间】:2016-11-10 06:47:51
【问题描述】:
我正在尝试使用 docker 上的 python/psycopg2 将大数据 (15 B) 从一个数据库 (postgresql) 传输到另一个数据库。我的 docker 有 4 GB 的内存并且内存不足。
我做错了什么?
cursor = conn.cursor()
cursor.execute('select * from schema.table')
for row in cursor:
tp = tuple(map(lambda x: x.encode('utf-8'), row)
cursor.execute('Insert into table2 values {}'.format(tp))
conn.commit()
【问题讨论】:
-
看看这里:stackoverflow.com/a/10147451/771848。希望对您有所帮助。
-
谢谢。但我的问题是光标,它将所有数据都存储到内存中。
标签: python postgresql docker psycopg2