代码:
#!/usr/bin/env python # encoding: utf-8 """ @author: 侠之大者kamil @file: mysql_test.py @time: 2016/4/7 17:38 """ import pymysql db= pymysql.connect("xzdz.hk","myuser","passwdxxxx","python_one",charset="utf8") #打开数据库连接 cursor = db.cursor()## 使用 cursor() 方法创建一个游标对象 cursor cursor.execute("SELECT * FROM `sf_exportcompany_config`") data = cursor.fetchall() #fetchone() 方法获取单条数据 print(data) db.close()
#