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()

posted on 2019-12-26 21:07  星空6  阅读(2180)  评论(0编辑  收藏  举报

导航