1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
|
#coding=utf-8import MySQLdbconn = MySQLdb.Connect(host = '127.0.0.1',port=3306,user='root',passwd='',db='test',charset='utf8')cursor = conn.cursor()sql = "select * from orders"cursor.execute(sql)#获取总记录数print cursor.rowcount#获取一条数据rs = cursor.fetchone()print rs#获取3条数据,将从第二条开始rs = cursor.fetchmany(3)print rs#获取所有数据,返回所有的数据rs = cursor.fetchall()print rscursor.close()conn.close() |
【说明】:本文章由站长整理发布,文章内容不代表本站观点,如文中有侵权行为,请与本站客服联系(QQ:254677821)!