collections-cache 0.1.4__py3-none-any.whl → 0.1.5__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.
- collections_cache/collections_cache.py +17 -6
- {collections_cache-0.1.4.dist-info → collections_cache-0.1.5.dist-info}/METADATA +1 -1
- collections_cache-0.1.5.dist-info/RECORD +6 -0
- collections_cache-0.1.4.dist-info/RECORD +0 -6
- {collections_cache-0.1.4.dist-info → collections_cache-0.1.5.dist-info}/LICENSE +0 -0
- {collections_cache-0.1.4.dist-info → collections_cache-0.1.5.dist-info}/WHEEL +0 -0
@@ -28,7 +28,8 @@ class Collection_Cache:
|
|
28
28
|
|
29
29
|
def initialize_databases(self, db_path):
|
30
30
|
conn = sqlite3.connect(db_path)
|
31
|
-
|
31
|
+
self.configure_connection(conn)
|
32
|
+
#conn.execute("PRAGMA journal_mode=WAL;")
|
32
33
|
conn.execute("""
|
33
34
|
CREATE TABLE IF NOT EXISTS data(
|
34
35
|
key TEXT,
|
@@ -48,8 +49,9 @@ class Collection_Cache:
|
|
48
49
|
|
49
50
|
def get_all_keys(self, database):
|
50
51
|
conn = sqlite3.connect(database)
|
52
|
+
self.configure_connection(conn)
|
51
53
|
cursor = conn.cursor()
|
52
|
-
cursor.execute("PRAGMA journal_mode=WAL;")
|
54
|
+
#cursor.execute("PRAGMA journal_mode=WAL;")
|
53
55
|
cursor.execute("SELECT key FROM data;")
|
54
56
|
result = cursor.fetchall()
|
55
57
|
keys = [(line[0], database) for line in result]
|
@@ -62,8 +64,9 @@ class Collection_Cache:
|
|
62
64
|
database_to_insert = choice(self.databases_list)
|
63
65
|
#print(f"Inserting in {database_to_insert}")
|
64
66
|
conn = sqlite3.connect(database_to_insert)
|
67
|
+
self.configure_connection(conn)
|
65
68
|
cursor = conn.cursor()
|
66
|
-
cursor.execute("PRAGMA journal_mode=WAL;")
|
69
|
+
#cursor.execute("PRAGMA journal_mode=WAL;")
|
67
70
|
cursor.execute("INSERT INTO data(key, value) VALUES (?, ?);", (key, pickle.dumps(value)))
|
68
71
|
conn.commit()
|
69
72
|
conn.close()
|
@@ -73,8 +76,9 @@ class Collection_Cache:
|
|
73
76
|
#print(f"Updating key '{key}' in {self.keys_databases[key]}...")
|
74
77
|
database_to_update = self.keys_databases[key]
|
75
78
|
conn = sqlite3.connect(database_to_update)
|
79
|
+
self.configure_connection(conn)
|
76
80
|
cursor = conn.cursor()
|
77
|
-
cursor.execute("PRAGMA journal_mode=WAL;")
|
81
|
+
#cursor.execute("PRAGMA journal_mode=WAL;")
|
78
82
|
cursor.execute("UPDATE data SET value = ? WHERE key = ?;", (pickle.dumps(value), key))
|
79
83
|
conn.commit()
|
80
84
|
conn.close()
|
@@ -96,8 +100,9 @@ class Collection_Cache:
|
|
96
100
|
#print(database_to_search)
|
97
101
|
|
98
102
|
conn = sqlite3.connect(database_to_search)
|
103
|
+
self.configure_connection(conn)
|
99
104
|
cursor = conn.cursor()
|
100
|
-
cursor.execute("PRAGMA journal_mode=WAL;")
|
105
|
+
#cursor.execute("PRAGMA journal_mode=WAL;")
|
101
106
|
cursor.execute("SELECT value FROM data WHERE key = ?", (key,))
|
102
107
|
result = cursor.fetchall()
|
103
108
|
conn.close()
|
@@ -113,8 +118,9 @@ class Collection_Cache:
|
|
113
118
|
#print(database_to_search)
|
114
119
|
|
115
120
|
conn = sqlite3.connect(database_to_delete)
|
121
|
+
self.configure_connection(conn)
|
116
122
|
cursor = conn.cursor()
|
117
|
-
cursor.execute("PRAGMA journal_mode=WAL;")
|
123
|
+
#cursor.execute("PRAGMA journal_mode=WAL;")
|
118
124
|
cursor.execute("DELETE FROM data WHERE key = ?", (key,))
|
119
125
|
conn.commit()
|
120
126
|
conn.close()
|
@@ -125,3 +131,8 @@ class Collection_Cache:
|
|
125
131
|
|
126
132
|
except Exception as error:
|
127
133
|
return error
|
134
|
+
|
135
|
+
def configure_connection(self, conn):
|
136
|
+
conn.execute("PRAGMA journal_mode = WAL;")
|
137
|
+
conn.execute("PRAGMA synchronous = NORMAL;")
|
138
|
+
conn.execute("PRAGMA wal_autocheckpoint = 1000;")
|
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.1
|
2
2
|
Name: collections-cache
|
3
|
-
Version: 0.1.
|
3
|
+
Version: 0.1.5
|
4
4
|
Summary: Collection Cache is a Python package for managing data collections across multiple SQLite databases. It allows efficient storage, retrieval, and updating of key-value pairs, supporting various data types serialized with pickle. The package uses parallel processing for fast access and manipulation of large collections.
|
5
5
|
License: MIT
|
6
6
|
Author: Luiz-Trindade
|
@@ -0,0 +1,6 @@
|
|
1
|
+
collections_cache/__init__.py,sha256=uUp8lhp-HnZRumnU_8MT6qVq95t0pOzn7oLW7ARbnvc,48
|
2
|
+
collections_cache/collections_cache.py,sha256=y85cIYXZW9j_CxKqnrV2OnwbBK6s9fwaBY5-woe32Ro,5288
|
3
|
+
collections_cache-0.1.5.dist-info/LICENSE,sha256=RAIL-FmXSiNRgyiVlfhm2SvVI4XDVsN0jDt9207SJ8o,1168
|
4
|
+
collections_cache-0.1.5.dist-info/METADATA,sha256=dtrLBINwp9heD8SomfCfx2hxoXhyUu0jfFg10kqZiYw,3199
|
5
|
+
collections_cache-0.1.5.dist-info/WHEEL,sha256=sP946D7jFCHeNz5Iq4fL4Lu-PrWrFsgfLXbbkciIZwg,88
|
6
|
+
collections_cache-0.1.5.dist-info/RECORD,,
|
@@ -1,6 +0,0 @@
|
|
1
|
-
collections_cache/__init__.py,sha256=uUp8lhp-HnZRumnU_8MT6qVq95t0pOzn7oLW7ARbnvc,48
|
2
|
-
collections_cache/collections_cache.py,sha256=8ZB0y8eJS1SFx8GEv-DQLlCyeqSL9VrNjRJz94gW_PE,4821
|
3
|
-
collections_cache-0.1.4.dist-info/LICENSE,sha256=RAIL-FmXSiNRgyiVlfhm2SvVI4XDVsN0jDt9207SJ8o,1168
|
4
|
-
collections_cache-0.1.4.dist-info/METADATA,sha256=uBO0-VHiAmD9shxP_9e4y6TI5Wi3gbvB6dGkodrtH_8,3199
|
5
|
-
collections_cache-0.1.4.dist-info/WHEEL,sha256=sP946D7jFCHeNz5Iq4fL4Lu-PrWrFsgfLXbbkciIZwg,88
|
6
|
-
collections_cache-0.1.4.dist-info/RECORD,,
|
File without changes
|
File without changes
|