当前位置:网站首页>SQLServer连接数据库读取中文乱码问题解决
SQLServer连接数据库读取中文乱码问题解决
2022-07-06 00:06:00 【瘾ิۣۖิۣۖิۣۖิꦿ】
在一个大二的数据库课设,在一个月黑风高的晚上,我猛然发现,在pycharm终端出现了我从未见过的字符,原来是读取的中文显示出现了乱码,然后一顿操作猛如虎,开始疯狂百度,在两个小时后,我得到了问题的原因。
因为SQLServer不支持UTF-8,当使用varchar保存汉字时,会出现乱码,需要转换。
cast函数
我们将需要选择展示的列,利用cast函数,用nvarchar保存汉字,就可以解决中文乱码的问题
select cast(xx as nvarchar(20)) xxxx …
def showall(self):
self.model.removeRows(0, self.model.rowCount())
sql = "SELECT OwnerId,cast(OwnerName as nvarchar(20)),cast(OwnerSex as nvarchar(20)),OwnerBir,OwnerPhone,OwnerIdent,BuildId,RoomId FROM Owner"
self.cur.execute(sql)
rows = self.cur.fetchall()
print(rows)
self.addItem(rows)边栏推荐
- What if the C disk is not enough? Let's see how I can clean up 25g of temp disk space after I haven't redone the system for 4 years?
- Hudi of data Lake (2): Hudi compilation
- 用列表初始化你的vector&&initializer_list简介
- 关于结构体所占内存大小知识
- USB Interface USB protocol
- My colleagues quietly told me that flying Book notification can still play like this
- 行列式学习笔记(一)
- Priority queue (heap)
- shardingsphere源码解析
- 云呐|固定资产管理系统主要操作流程有哪些
猜你喜欢

Transport layer protocol ----- UDP protocol

Ffmpeg learning - core module

Single merchant v4.4 has the same original intention and strength!

PV静态创建和动态创建

Hardware and interface learning summary

Effet Doppler (déplacement de fréquence Doppler)

There is no network after configuring the agent by capturing packets with Fiddler mobile phones

Gd32f4xx UIP protocol stack migration record

Tools to improve work efficiency: the idea of SQL batch generation tools

20220703 week race: number of people who know the secret - dynamic rules (problem solution)
随机推荐
openssl-1.0.2k版本升级openssl-1.1.1p
[Luogu cf487e] tours (square tree) (tree chain dissection) (line segment tree)
Use CAS instead of synchronized
Convert Chinese into pinyin
Add noise randomly to open3d point cloud
Laser slam learning record
【DesignMode】适配器模式(adapter pattern)
Ffmpeg learning - core module
MySQL之函数
微信小程序---WXML 模板语法(附带笔记文档)
Make a short video clip number of we media film and television. Where can I download the material?
wx. Getlocation (object object) application method, latest version
Mathematical model Lotka Volterra
14 MySQL view
Permission problem: source bash_ profile permission denied
Teach you to run uni app with simulator on hbuilderx, conscience teaching!!!
Asynchronous task Whenall timeout - Async task WhenAll with timeout
There is no network after configuring the agent by capturing packets with Fiddler mobile phones
什么叫做信息安全?包含哪些内容?与网络安全有什么区别?
[SQL] SQL expansion languages of mainstream databases (T-SQL, pl/sql, pl/pgsql)