python往postgres里面写数据遇到\x00 NULL 字元的问题

各位大佬 我现在有个需求,需要用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'


遍历列表元素,即对字符串进行处理,像这样:
new=[]
for r in rows:
r.decode("utf-8", errors="replace").replace("\x00", "\uFFFD")
new.append(r)

扣扣

将oracle数据读取出来!
在读取select时,做一下replace替换,把\x00替换成你能接受的字符,或者空。

while True: 
  rows = coure_select.fetchmany(1000) 
  new=[] 
  for r in rows: 
    r.decode("utf-8", errors="replace").replace("\x00", "\uFFFD") 
    new.append(r)     
  coure_insert.executemany(insert_sql,new) get_insrt_database.commit()

改成这个还是报错
File "d:\python\python\one_100day\20210622_trans_pg_pallel.py", line 146, in insert_table_pallel
r.decode("utf-8", errors="replace").replace("\x00", "\uFFFD")
AttributeError: 'tuple' object has no attribute 'decode'