python3 根据条件查询mysql数据库中数据;

import pymysql
ecshop=pymysql.connect('localhost','root','root','ecshop')
curs=ecshop.cursor()
sql="select consignee,email,tel from ecs_user_address where address_id>3 "
try:
curs.execute(sql)
a=curs.fetchall() #接收全部的返回结果;
print(a)
for i in a:
print(i)
except:
print('wrong')
ecshop.close()

越努力,越幸运!!! good good study,day day up!!!
原文地址:https://www.cnblogs.com/canglongdao/p/12104415.html