【pymysql模块】:连接数据库操作
import pymysql
db = pymysql.connect(
host = 'xxx',
port = xxx,
user = 'xxx',
passwd = 'xxx',
db = 'xxx',
charset = 'utf8mb4',
)
#启用游标
cursor = db.cursor()
#游标执行sql
cursor.execute(sql语句)
result_sql = cursor.fetchall()