12-09
12-09
12-09
12-09
12-09
12-09
12-09
12-09
12-09
12-09
12-09
12-09
ADADADADAD
mysql数据库 时间:2024-12-24 19:13:24
作者:文/会员上传
12-09
12-09
12-09
12-09
12-09
12-09
12-09
12-09
12-09
12-09
12-09
12-09
#/usr/bin/envpython#__*__coding:utf8__*__zbx_host='10.1.12.100'zbx_port=3306zbx_username='zabbix'zbx_password='123456'zbx_dbname='zabbix'groupname='其他部门'con
以下为本文的正文内容,内容仅供参考!本站为公益性网站,复制本文以及下载DOC文档全部免费。
#/usr/bin/envpython#__*__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='''selectgroupidfromgroupswherename='%s''''%groupnamecursor.execute(sql)printcursor.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
11-20
11-19
11-20
11-20
11-20
11-19
11-20
11-20
11-19
11-20
11-19
11-19
11-19
11-19
11-19
11-19