pip install pymysql
# -*-coding:utf-8 -*-
import pymysql
conn = pymysql.connect(host='127.0.0.1', user = "root", passwd="root", db="test", port=3306, charset="utf8")
cur = conn.cursor()
#查询数据
cur.execute("select * from test where to_days(addtime) = to_days(now()) order by test.int desc")
#获取数据
users = cur.fetchall();
for i in range(len(users)):
print(users[i]);
#关闭资源连接
cur.close()
conn.close()
print('关闭')