用python语言从MySQL中查询数据
#!conding:utf-8 from mysql.connector import errorcode import mysql.connector cnx=None cursor=None try: 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 x except mysql.connector.Error,err: print err finally: if cursor is not None: cursor.close() cnx.close()