我一直在寻找这个错误我得到了大量答案,但没有解决我的问题。
我试图导入一些表但有些表示这个错误,我不知道如何解决它
我的代码:
hostname = '192.168.0.50'
username = 'aasd
password = 'asdasd'
database = 'db1'
def doQuery( conn ):
cur = conn.cursor()
comando_sql = """SELECT os.numos,
ccusto.nomecc,prest.nomeprest,equip.especifica
from osmanut as os
left join cadcc as ccusto on os.codccserv = ccusto.codcc
left join cadprest as prest on os.prestsolic = prest.codprest
left join cadeqman as equip on os.codequipa = equip.codequipa
where codtecos = '007' and CAST(os.dataconclu AS DATE) = '2017-07-05' order by os.numos"""
cur.execute (comando_sql)
arq = open("relatorio_diario.txt", "w")
rows = cur.fetchall()
for row in rows:
numos = row[0]
setor = row[1]
solicitante = row[2]
equip_nome = row[3]
solicitante = solicitante if solicitante is not None else "Nao Informado"
equip_nome = equip_nome if equip_nome is not None else "Nao Informado"
arq.write('_OS: {} - Setor: {} - Solicitante: {}\n - Equipamento: {}\n Resolucao: '.format(numos, setor, solicitante, equip_nome))
arq.write("\n")
arq.write("------------------------------------------------------")
arq.write("\n")
arq.close()
import psycopg2
myConnection = psycopg2.connect(host=hostname, user=username, password=password, dbname=database)
doQuery( myConnection )
myConnection.close()
我得到的错误 UnicodeDecodeError:' ascii'编解码器不能解码位置272中的字节0xc3:序数不在范围内(128)