用python语言从MySQL中查询数据
#!conding:utf-8from mysql.connector import errorcodeimport mysql.connectorcnx=Nonecursor=Nonetry: cnx = mysql.connector.connect(host='192.168.1.201',port=3306,user='admin',password='131417') cursor=cnx.cursor() cursor.execute('select * from studio.t where id=%s',(7,)) for x in cursor: print xexcept mysql.connector.Error,err: print errfinally: if cursor is not None: cursor.close() cnx.close()