con = pymysql.connect(host='localhost',user='root',passwd='cbj123',port=3306,db='bigdata')
cur = con.cursor()
sql ='select * from phone'
sql1 ='select num from hero order by num desc limit 0,11'
cur.execute(sql)
see = cur.fetchall()
cur.execute(sql1)
see1 = cur.fetchall().........
cur.close()
con.close()
遍历数据:
data1 =[]
data2 =[]
data3 =[]for data in see:
data1.append(data[0])
data2.append(data[1])for data in see1:
data3.append(data[0])
连接数据库创建游标:con = pymysql.connect(host='localhost',user='root',passwd='cbj123',port=3306,db='bigdata')cur = con.cursor()sql = 'select * from phone'sql1 = 'select num from hero order by num desc limi...