当前位置:网站首页>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)边栏推荐
- Global and Chinese market of water heater expansion tank 2022-2028: Research Report on technology, participants, trends, market size and share
- 【QT】Qt使用QJson生成json文件并保存
- Make a short video clip number of we media film and television. Where can I download the material?
- 2022.7.5-----leetcode.729
- Configuring OSPF load sharing for Huawei devices
- QT QPushButton details
- Choose to pay tribute to the spirit behind continuous struggle -- Dialogue will values [Issue 4]
- What is information security? What is included? What is the difference with network security?
- Qt 一个简单的word文档编辑器
- wx.getLocation(Object object)申请方法,最新版
猜你喜欢
随机推荐
Make a short video clip number of we media film and television. Where can I download the material?
7.5 decorator
[Luogu cf487e] tours (square tree) (tree chain dissection) (line segment tree)
20220703 week race: number of people who know the secret - dynamic rules (problem solution)
单商户V4.4,初心未变,实力依旧!
Configuring OSPF load sharing for Huawei devices
Gavin teacher's perception of transformer live class - rasa project actual combat e-commerce retail customer service intelligent business dialogue robot system behavior analysis and project summary (4
What are the functions of Yunna fixed assets management system?
Transport layer protocol ----- UDP protocol
行列式学习笔记(一)
China Jinmao online electronic signature, accelerating the digitization of real estate business
Online yaml to CSV tool
激光slam学习记录
【在线聊天】原来微信小程序也能回复Facebook主页消息!
[Luogu p3295] mengmengda (parallel search) (double)
[binary search tree] add, delete, modify and query function code implementation
18.(arcgis api for js篇)arcgis api for js点采集(SketchViewModel)
[noi simulation] Anaid's tree (Mobius inversion, exponential generating function, Ehrlich sieve, virtual tree)
JVM details
多普勒效应(多普勒频移)









