开发喵星球

python

python

import pymysql

# 建立与数据库的连接
conn = pymysql.connect(host='localhost', port=3306, user='root', password='password', database='mydatabase')
cursor = conn.cursor()

# 执行查询语句
sql = "SELECT * FROM mytable"
cursor.execute(sql)
result = cursor.fetchall()
print(result)

# 关闭连接
cursor.close()
conn.close()
   
分类:金斗云 作者:开发喵 发表于:2024-04-01 23:18:10 阅读量:88
<<   >>


powered by kaifamiao