pymql练习,查询数据

上代码:

# -*- coding:utf-8 -*-  
import pymysql
con=pymysql.connect(host='localhost',user='root',password='123456',database='ges_data',port=3306)
cur=con.cursor()

sql='select * from t_student where age=23'

try:
    cur.execute(sql)
    students=cur.fetchall()
    print(students)
except Exception as e:
    print(e) 
finally:
    con.close()
发布了15 篇原创文章 · 获赞 12 · 访问量 222

猜你喜欢

转载自blog.csdn.net/weixin_45116096/article/details/105471376
今日推荐