#/usr/bin/env python#__*__coding:utf8__*__zbx_host = ' 10.1.12.100 ' zbx_port = 3306zbx_username = ' Zabbix ' Zbx_password = ' 123456 ' zbx_dbname = ' Zabbix ' groupname = ' other department ' 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 '% gro Upnamecursor.execute (SQL) print Cursor.fetchall ()
When groupname = ' other department ', has not found the data, has been empty, but will groupname = ' templates ' when there is data, I feel is not support Chinese, the database itself code is UTF8 650) this.width=650; " Src= "Http://img.baidu.com/hi/jx2/j_0004.gif" alt= "J_0004.gif"/>
Stole a bit of the great God wrote the post 650) this.width=650; "src=" Http://img.baidu.com/hi/bobo/B_0018.gif "alt=" B_0018.gif "/> found that the MYSQLDB plug-in also to the connection when the Declaration, not long use Chinese script, has not been found.
conn = MySQLdb.connect (host = Zbx_host,port = Zbx_port,user = zbx_username, passwd = zbx_password,db = Zbx_dbname, Char set = "UTF8")
Add a parameter just fine, toss a good long time 650) this.width=650; "src=" Http://img.baidu.com/hi/bobo/B_0062.gif "alt=" B_0062.gif "/>
Reference:
http://blog.csdn.net/dszgf5717/article/details/50985816
This article is from the "LINUX" blog, so be sure to keep this source http://wangpengtai.blog.51cto.com/3882831/1946275
MySQLdb query with Chinese keyword cannot find data