用到模块pymysql,用pip安装

sudo pip3 install pymysql3

编写程序

import pymysql

conn = pymysql.connect(host='127.0.0.1', port=3306, user='root', passwd='123',db='girl')

cur = conn.cursor()

cur.execute("SELECT * FROM student")

for r in cur.fetchall():

           print(r)

cur.close()

conn.close()

 

相关文章:

  • 2022-12-23
  • 2021-11-21
  • 2021-11-21
  • 2022-03-08
  • 2021-05-22
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2021-11-21
  • 2021-11-21
  • 2021-09-27
  • 2022-12-23
相关资源
相似解决方案