-
Notifications
You must be signed in to change notification settings - Fork 0
/
clear.py
47 lines (41 loc) · 995 Bytes
/
clear.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
# -*- coding: utf-8 -*-
import time
from clear_config import recordkept
from Monitor import Monitor
M = Monitor()
M.log("running clear", logtype="clear")
dbs = [
'bot_message',
'error',
'log',
'RC_142',
'RC_categorize',
'RC_edit',
'RC_log_abusefilter_modify',
'RC_log_abuselog',
'RC_log_block',
'RC_log_delete',
'RC_log_delete_restore',
'RC_log_delete_revision',
'RC_log_gblblock',
'RC_log_gblrename',
'RC_log_globalauth',
'RC_log_merge',
'RC_log_move',
'RC_log_newusers',
'RC_log_patrol',
'RC_log_protect',
'RC_log_protect_move_prot',
'RC_log_protect_unprotect',
'RC_log_renameuser',
'RC_log_rights',
'RC_log_thanks',
'RC_log_upload',
'RC_new'
]
timestamp = str(int(time.time() - recordkept))
for db in dbs:
rows = M.cur.execute(f"""DELETE FROM {db} WHERE `timestamp` < %s""",
(timestamp))
M.db.commit()
print(f"delete {rows} rows from {db}")