import pymysql as mysql
from DBUtils.PooledDB import PooledDB
pool = PooledDB(mysql,
5,
host='阿里提供的远程host',
user='用户账户',
passwd='用户密码',
db='查询的库名',
port=3306,
)
conn = pool.connection()
cur = conn.cursor()
cur.execute('sql语句')
all_datas = cur.fetchall()
print(all_datas)
cur.close()
conn.close()