MySQLdb查询有中文关键字查不到数据
发表于:2024-09-25 作者:千家信息网编辑
千家信息网最后更新 2024年09月25日,#/usr/bin/env python#__*__coding:utf8__*__zbx_host = '10.1.12.100'zbx_port = 3306zbx_username = 'zab
千家信息网最后更新 2024年09月25日MySQLdb查询有中文关键字查不到数据
#/usr/bin/env python#__*__coding:utf8__*__zbx_host = '10.1.12.100'zbx_port = 3306zbx_username = 'zabbix'zbx_password = '123456'zbx_dbname = 'zabbix'groupname = '其他部门'conn = MySQLdb.connect(host = zbx_host,port = zbx_port,user = zbx_username, passwd = zbx_password,db = zbx_dbname)cursor = conn.cursor()sql = '''select groupid from groups where name='%s' ''' % groupnamecursor.execute(sql)print cursor.fetchall()
当groupname = '其他部门'的时候,一直没有查到数据,一直为空,但是将groupname = 'templates'时就有数据了,我感觉是不支持中文,数据库本身编码是utf8的
剽窃了一下下人家大神写的帖子发现MySQLdb插件还要在连接时声明一下,不长使用中文写脚本,一直没发现。
conn = MySQLdb.connect(host = zbx_host,port = zbx_port,user = zbx_username, passwd = zbx_password,db = zbx_dbname,charset = "utf8")
加个参数就好了,折腾了好长时间
参考:
http://blog.csdn.net/dszgf5717/article/details/50985816
数据
部门
中文
参数
大神
帖子
感觉
插件
数据库
时候
编码
脚本
长时
参考
支持
关键
关键字
有中文
查询
数据库的安全要保护哪些东西
数据库安全各自的含义是什么
生产安全数据库录入
数据库的安全性及管理
数据库安全策略包含哪些
海淀数据库安全审计系统
建立农村房屋安全信息数据库
易用的数据库客户端支持安全管理
连接数据库失败ssl安全错误
数据库的锁怎样保障安全
网络安全理论架构
dbf数据库 赋值 时间
服务器与设备的关系
2016年国家网络安全宣传周主题
轮回服魔兽世界服务器叫什么
商务软件开发工程师
数据库改字符集
软件无法获取数据库数据
检察院落实网络安全责任制
电视投屏无法连接到服务器
梦幻风华正茂服务器
网络技术学习自律
米3路由器有打印机服务器吗
山东省考网络安全管理职位
国外服务器安全产品
网络安全大赛sp战队
网络安全工作实施方案
软件开发培训机构能去吗
数据库系统的缩写
什么是服务器安全管理协议
行业软件开发公司哪家好
移动20万台服务器
网络安全宣传画wuzi
服务器电源有什么作用
浙江省杭州十大软件开发
合肥市网络安全技术服务单位
乐橙互联网科技
欧洲卡车线上不限速服务器是哪个
新型网络技术排名靠前
ibm服务器风扇