# 导入模块
import pymysql
# 连接数据库
mysql_conn = pymysql.connect(host="127.0.0.1",
                             port=3306,
                             user="root",
                             password="",
                             charset="utf8",
                             db="t1")
# 获取游标
c = mysql_conn.cursor(cursor=pymysql.cursors.DictCursor)
# SQL语句
sql = "select * from users WHERE name='jwb' and age=73 "
# 执行SQL
res = c.execute(sql)
# 打印结果
print(c.fetchall())
# 关闭游标
c.close()
# 关闭数据库
mysql_conn.close()

 

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-04-29
  • 2021-12-15
  • 2022-12-23
  • 2021-12-10
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2021-11-21
  • 2022-12-23
  • 2021-11-21
  • 2021-10-11
  • 2021-11-10
相关资源
相似解决方案