linkarchivetools 0.1.15__py3-none-any.whl → 0.1.17__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- linkarchivetools/dbfilter.py +11 -5
- linkarchivetools/utils/reflected.py +10 -0
- {linkarchivetools-0.1.15.dist-info → linkarchivetools-0.1.17.dist-info}/METADATA +1 -1
- {linkarchivetools-0.1.15.dist-info → linkarchivetools-0.1.17.dist-info}/RECORD +6 -6
- {linkarchivetools-0.1.15.dist-info → linkarchivetools-0.1.17.dist-info}/LICENSE +0 -0
- {linkarchivetools-0.1.15.dist-info → linkarchivetools-0.1.17.dist-info}/WHEEL +0 -0
linkarchivetools/dbfilter.py
CHANGED
|
@@ -13,6 +13,7 @@ import argparse
|
|
|
13
13
|
|
|
14
14
|
from sqlalchemy import create_engine
|
|
15
15
|
from .utils.reflected import *
|
|
16
|
+
from .tableconfig import get_tables
|
|
16
17
|
|
|
17
18
|
|
|
18
19
|
class DbFilter(object):
|
|
@@ -53,7 +54,12 @@ class DbFilter(object):
|
|
|
53
54
|
self.connection = None
|
|
54
55
|
|
|
55
56
|
def truncate(self):
|
|
56
|
-
|
|
57
|
+
"""
|
|
58
|
+
TODO remove these hardcoded tables
|
|
59
|
+
with something from table_config
|
|
60
|
+
though it seems it should not clear linkdatamodel
|
|
61
|
+
"""
|
|
62
|
+
table = ReflectedTable(self.engine, self.connection)
|
|
57
63
|
|
|
58
64
|
table.truncate_table("userentrytransitionhistory")
|
|
59
65
|
table.truncate_table("userentryvisithistory")
|
|
@@ -78,7 +84,7 @@ class DbFilter(object):
|
|
|
78
84
|
table.truncate_table("blockentrylist")
|
|
79
85
|
|
|
80
86
|
def filter(self, conditions):
|
|
81
|
-
table =
|
|
87
|
+
table = ReflectedTable(self.engine, self.connection)
|
|
82
88
|
|
|
83
89
|
sql_text = f"DELETE FROM linkdatamodel WHERE {conditions};"
|
|
84
90
|
# TODO delete depnded things
|
|
@@ -87,7 +93,7 @@ class DbFilter(object):
|
|
|
87
93
|
table.close()
|
|
88
94
|
|
|
89
95
|
def filter_bookmarks(self):
|
|
90
|
-
table =
|
|
96
|
+
table = ReflectedTable(self.engine, self.connection)
|
|
91
97
|
|
|
92
98
|
sql_text = f"DELETE FROM linkdatamodel WHERE bookmarked=False;"
|
|
93
99
|
# TODO delete depnded things
|
|
@@ -96,7 +102,7 @@ class DbFilter(object):
|
|
|
96
102
|
table.close()
|
|
97
103
|
|
|
98
104
|
def filter_votes(self):
|
|
99
|
-
table =
|
|
105
|
+
table = ReflectedTable(self.engine, self.connection)
|
|
100
106
|
|
|
101
107
|
sql_text = f"DELETE FROM linkdatamodel WHERE page_rating_votes=0;"
|
|
102
108
|
table.run_sql(sql_text)
|
|
@@ -107,7 +113,7 @@ class DbFilter(object):
|
|
|
107
113
|
"""
|
|
108
114
|
Not bookmarked AND without votes are redundant
|
|
109
115
|
"""
|
|
110
|
-
table =
|
|
116
|
+
table = ReflectedTable(self.engine, self.connection)
|
|
111
117
|
|
|
112
118
|
sql_text = f"DELETE FROM linkdatamodel WHERE bookmarked=False AND page_rating_votes=0;"
|
|
113
119
|
table.run_sql(sql_text)
|
|
@@ -42,6 +42,11 @@ class ReflectedTable(object):
|
|
|
42
42
|
|
|
43
43
|
index.create(bind=self.engine)
|
|
44
44
|
|
|
45
|
+
def enable_sqlite_wal(self, table_name):
|
|
46
|
+
sql_text = f"PRAGMA journal_mode=WAL;"
|
|
47
|
+
self.connection.execute(text(sql_text))
|
|
48
|
+
self.connection.commit()
|
|
49
|
+
|
|
45
50
|
def vacuum(self):
|
|
46
51
|
self.connection.execute(text("VACUUM"))
|
|
47
52
|
|
|
@@ -129,6 +134,11 @@ class ReflectedGenericTable(object):
|
|
|
129
134
|
self.connection.execute(text(sql_text))
|
|
130
135
|
self.connection.commit()
|
|
131
136
|
|
|
137
|
+
def enable_sqlite_wal(self):
|
|
138
|
+
sql_text = f"PRAGMA journal_mode=WAL;"
|
|
139
|
+
self.connection.execute(text(sql_text))
|
|
140
|
+
self.connection.commit()
|
|
141
|
+
|
|
132
142
|
def create_index(self, column_name):
|
|
133
143
|
index_name = f"idx_{self.table.name}_{column_name}"
|
|
134
144
|
index = Index(index_name, getattr(table.c, column_name))
|
|
@@ -5,14 +5,14 @@ linkarchivetools/backup.py,sha256=xUDpC0YZou0y2X1aa-Js8pS_3TnC_NmVfKSrVihQd8A,24
|
|
|
5
5
|
linkarchivetools/db2feeds.py,sha256=P5ZvvyLoEEOPPU_a50VlWw9FNMw8MyFg1TBR_ftdgQ4,8871
|
|
6
6
|
linkarchivetools/db2json.py,sha256=gCuCVqn4n40i1-6-k_Hb809bq2q8VgfIEHrFWp6nBT8,5666
|
|
7
7
|
linkarchivetools/dbanalyzer.py,sha256=BD59Ieg7Xv9pMgLZzWlN--8uReEYovfJ2XMbTsV5-Jg,10125
|
|
8
|
-
linkarchivetools/dbfilter.py,sha256=
|
|
8
|
+
linkarchivetools/dbfilter.py,sha256=n_yzMRt-exS3jkyiWcpUSy7B37RkzXEyUTH7-DWdUD0,4697
|
|
9
9
|
linkarchivetools/dbmerge.py,sha256=dEkvnYfiRDV3Od8qVQJWP_qJ7SKOYqKCndeX2HAJKFE,2510
|
|
10
10
|
linkarchivetools/json2db.py,sha256=IF01_KhMmHcdm4jfagU_kuJGCEtRwgwjZDuxLtlT7EQ,7607
|
|
11
11
|
linkarchivetools/tableconfig.py,sha256=TsYYl2kbAkP035XElHUmeJqH5Kugl7bwi4ClIwJ6MSA,1731
|
|
12
12
|
linkarchivetools/utils/alchemysearch.py,sha256=voUDEBP4RShlGj8E0iHg83jP8JYJQKLOaJjCZNi4LMY,5689
|
|
13
13
|
linkarchivetools/utils/omnisearch.py,sha256=7HVzz8LesS3Yo6exdlPf4WdPbi2DQekPR2CmkJcfBbI,10115
|
|
14
|
-
linkarchivetools/utils/reflected.py,sha256=
|
|
15
|
-
linkarchivetools-0.1.
|
|
16
|
-
linkarchivetools-0.1.
|
|
17
|
-
linkarchivetools-0.1.
|
|
18
|
-
linkarchivetools-0.1.
|
|
14
|
+
linkarchivetools/utils/reflected.py,sha256=o0_DOMNAF8b1dbOz3gFFB5YyTuqRYsiIQPA9v2fPQUQ,16076
|
|
15
|
+
linkarchivetools-0.1.17.dist-info/LICENSE,sha256=OXLcl0T2SZ8Pmy2_dmlvKuetivmyPd5m1q-Gyd-zaYY,35149
|
|
16
|
+
linkarchivetools-0.1.17.dist-info/METADATA,sha256=UvRtshlyJZZJ2fg9D7mMafKr9NNVpaYQ_uk9UIs7mRw,1203
|
|
17
|
+
linkarchivetools-0.1.17.dist-info/WHEEL,sha256=sP946D7jFCHeNz5Iq4fL4Lu-PrWrFsgfLXbbkciIZwg,88
|
|
18
|
+
linkarchivetools-0.1.17.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|