python操作mysql数据库mysql_operation

时间:2020-09-28 11:03:05
【文件属性】:
文件名称:python操作mysql数据库mysql_operation
文件大小:222KB
文件格式:EXE
更新时间:2020-09-28 11:03:05
python 使用前需先安装mysql-python,下载地址https://pypi.python.org/pypi/MySQL-python/1.2.5,以下是使用mysql_operation查询一个学生表全部数据的demo: #-*- coding: utf-8 -*- from mysql_operation import MysqlOperation mysql=MysqlOperation("127.0.0.1","root","123456",3306,"student") data_list=mysql.excuteFindAll("select * from tb_student") print data_list 返回数据类型: [{'stuName': u'\u5f20\u4e09', 'gender': u'\u7537', 'id': 1L, 'stuAge': 23L}, {'stuName': u'\u674e\u56db', 'gender': u'\u7537', 'id': 2L, 'stuAge': 21L}, {'stuName': u'\u738b\u4e94', 'gender': u'\u7537', 'id': 3L, 'stuAge': 24L}, {'stuName': u'\u738b\u9ebb\u5b50', 'gender': u'\u7537', 'id': 4L, 'stuAge': 25L}, {'stuName': u'\u9ec4\u4e09', 'gender': u'\u7537', 'id': 5L, 'stuAge': 23L}, {'stuName': u'\u738b\u7ea2', 'gender': u'\u5973', 'id': 14L, 'stuAge': 22L}

网友评论