pymssql读取mysql数据库乱码问题
用的字符窜,要么结果是乱码,要么没得乱码,但某些列是空值
有懂的,我发代码给你们,帮忙解决一下
com = pymssql.connect(server='', user='', password='@123#*', database='hydee_dxt')
cursor = com.cursor()
sql = f"""select warename,wareid,barcode,warespec,producer,advsaleprice from {table[0]}"""
cursor.execute(sql)
res = cursor.fetchall()
col = [i[0] for i in cursor.description]
df = pd.DataFrame(res, columns=col).apply(
lambda x: x.astype(str).str.encode('utf8').str.decode('cp1250'))
print(df)