|
@@ -2,6 +2,7 @@ import time
|
|
import traceback
|
|
import traceback
|
|
|
|
|
|
import oss2
|
|
import oss2
|
|
|
|
+from django.db import connection, connections
|
|
from django.utils.decorators import method_decorator
|
|
from django.utils.decorators import method_decorator
|
|
from django.views.decorators.csrf import csrf_exempt
|
|
from django.views.decorators.csrf import csrf_exempt
|
|
from django.views.generic import TemplateView
|
|
from django.views.generic import TemplateView
|
|
@@ -289,16 +290,19 @@ class EquipmentInfo(View):
|
|
use information_schema;
|
|
use information_schema;
|
|
select concat(round(sum(data_length/1024/1024),2),'MB') as data from tables where table_schema='Ansjer81';
|
|
select concat(round(sum(data_length/1024/1024),2),'MB') as data from tables where table_schema='Ansjer81';
|
|
'''
|
|
'''
|
|
-# 删除访问日志
|
|
|
|
|
|
+# 定时删除推送数据
|
|
def deleteExpireEquipmentInfo(request):
|
|
def deleteExpireEquipmentInfo(request):
|
|
response = ResponseObject()
|
|
response = ResponseObject()
|
|
import time
|
|
import time
|
|
nowTime = int(time.time())
|
|
nowTime = int(time.time())
|
|
|
|
+ cursor = connections['mysql02'].cursor()
|
|
try:
|
|
try:
|
|
for i in range(10):
|
|
for i in range(10):
|
|
- ei = Equipment_Info.objects.filter(addTime__lte=str(nowTime - 3600 * 24 * 7))[0:10000]
|
|
|
|
- id_list = list(ei.values_list("id", flat=True))
|
|
|
|
- Equipment_Info.objects.filter(id__in=id_list).delete()
|
|
|
|
|
|
+ # 删除7天前的数据
|
|
|
|
+ sql = "DELETE FROM `equipment_info` WHERE addTime<={} LIMIT 10000".format(nowTime - 3600 * 24 * 7)
|
|
|
|
+ cursor.execute(sql)
|
|
|
|
+ # 关闭游标
|
|
|
|
+ cursor.close()
|
|
return response.json(0)
|
|
return response.json(0)
|
|
except Exception as e:
|
|
except Exception as e:
|
|
return response.json(500, repr(e))
|
|
return response.json(500, repr(e))
|