当前位置:网站首页>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)
边栏推荐
- Shardingsphere source code analysis
- Tips for using pads router
- 18.(arcgis api for js篇)arcgis api for js点采集(SketchViewModel)
- [day39 literature extensive reading] a Bayesian perspective on magnetic estimation
- 跟着CTF-wiki学pwn——ret2libc1
- The use of El cascader and the solution of error reporting
- Miaochai Weekly - 8
- 7.5 decorator
- Mysql - CRUD
- Open source CRM customer relationship system management system source code, free sharing
猜你喜欢
妙才周刊 - 8
认识提取与显示梅尔谱图的小实验(观察不同y_axis和x_axis的区别)
Doppler effect (Doppler shift)
MySql——CRUD
openssl-1.0.2k版本升级openssl-1.1.1p
What are the functions of Yunna fixed assets management system?
上门预约服务类的App功能详解
MySQL之函数
20220703 week race: number of people who know the secret - dynamic rules (problem solution)
云呐|公司固定资产管理系统有哪些?
随机推荐
Redis high availability - master-slave replication, sentinel mode, cluster
[EF core] mapping relationship between EF core and C data type
关于slmgr命令的那些事
[designmode] adapter pattern
Open source CRM customer relationship system management system source code, free sharing
Gd32f4xx UIP protocol stack migration record
After summarizing more than 800 kubectl aliases, I'm no longer afraid that I can't remember commands!
云呐|固定资产管理系统主要操作流程有哪些
PV static creation and dynamic creation
Hudi of data Lake (2): Hudi compilation
什么叫做信息安全?包含哪些内容?与网络安全有什么区别?
Zero rhino technology joined hands with the intelligence Club: the "causal faction" forum was successfully held, and the "causal revolution" brought the next generation of trusted AI
Single merchant v4.4 has the same original intention and strength!
多普勒效应(多普勒频移)
FFMPEG关键结构体——AVFrame
Open3D 点云随机添加噪声
MySql——CRUD
wx. Getlocation (object object) application method, latest version
Learn PWN from CTF wiki - ret2libc1
FFMPEG关键结构体——AVCodecContext