【发布时间】:2018-04-26 11:28:17
【问题描述】:
def import_from_csv(common_cols_tup, table_name):
"""
:param common_cols_tup: tuple of all columns
:param table_name: database table name
:return:
"""
with open('/tmp/%s.csv'%table_name, 'r') as f:
# Notice that we don't need the `csv` module.
next(f) # Skip the header row.
dest_cur.copy_from(f, table_name, sep=";",null='\\N', columns=common_cols_tup)
dest_cur.commit()
我在尝试这段代码时得到了跟踪
文件“migrate.py”,第 29 行,在 import_from_csv dest_cur.copy_from(f, table_name, sep=";",null='\N', columns=common_cols_tup) psycopg2.extensions.QueryCanceledError: COPY from stdin failed: error in .read() call: exceptions.ValueError 混合迭代和读取方法会丢失数据 上下文:复制 res_partner,第 1 行
【问题讨论】: