标签:blog os 数据 for ar div log 数据库
#encoding: utf-8 import mysql.connector __author__ = ‘Administrator‘ config={‘host‘:‘127.0.0.1‘,#默认127.0.0.1 ‘user‘:‘root‘, ‘password‘:‘root‘, ‘port‘:3306 ,#默认即为3306 ‘database‘:‘test‘, ‘charset‘:‘utf8‘#默认即为utf8 } if __name__=="__main__": print(config[‘host‘]) cnx =mysql.connector.connect(user=config[‘user‘],password=config[‘password‘],host=config[‘host‘],port=config[‘port‘],database=config[‘database‘]) cursor =cnx.cursor() cursor.execute("select * from job") for _row in cursor.fetchall(): print(_row[1]) pass
Python访问MySQL数据库,布布扣,bubuko.com
标签:blog os 数据 for ar div log 数据库
原文地址:http://www.cnblogs.com/likehua/p/3908319.html