123456789101112131415161718192021222324252627282930 |
- #!/usr/bin/python3.6
- # -*- coding: utf-8 -*-
- #
- # Copyright (C) 2022 #
- # @Time : 2022/4/1 11:27
- # @Author : ming
- # @Email : zhangdongming@asj6.wecom.work
- # @File : CronDelDataController.py
- # @Software: PyCharm
- from django.db import connection
- from Object.ResponseObject import ResponseObject
- from Object.utils import LocalDateTimeUtil
- def deleteExpireAccessLog(request):
- response = ResponseObject()
- try:
- print(request)
- cursor = connection.cursor()
- # 删除一个月前的数据
- last_month = LocalDateTimeUtil.get_last_month()
- sql = 'DELETE FROM access_log WHERE time < %s limit %s'
- cursor.execute(sql, [last_month, 10000])
- # 关闭游标
- cursor.close()
- connection.close()
- return response.json(0)
- except Exception as e:
- return response.json(500, repr(e))
|