各位大佬 我现在有个需求,需要用python将oracle数据读取出来然后插入到postgres里面,目前 报错:经过排查发现,只要字串里有\x00 NULL 字元,psycopg2 就会弹一个ValueError 的exception,内容就是 A string literal cannot contain NUL (0x00) characters.
现在我初步的想法是对取出来的数据进行值的替换,但是这一块我不知道如何替换列表中的字符串,求指点在下图中的代码 如何将\x00 NULL 字元替换掉
while True:
rows = coure_select.fetchmany(1000)
# rows.decode("utf-8", errors="replace").replace("\x00", "\uFFFD")
coure_insert.executemany(insert_sql,rows)
get_insrt_database.commit()
if not rows:
break #中断循环
百度了下 decode("utf-8", errors="replace").replace("\x00", "\uFFFD") 这段代码 但是加进去后报错 :
AttributeError: 'list' object has no attribute 'decode'