连接数据库
from django.db import connection
sql = "SELECT id,record_time,lose_time from old_user where lose_time>= \'" + str(today) + "\'"
cursor = connection.cursor()
查询数据库
cursor.execute(sql)
results = cursor.fetchall()#查询所有
results = cursor.fetchone()#查询一条
更新数据库
sql = "UPDATE old_user set lose_time=\'" + str(lose_time) + "\' where id = " + str(id)
cursor.execute(sql)
connection.connection.commit()#这里提交用法特殊,注意