tinykv 0.2.0__tar.gz → 0.3.0__tar.gz
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.
- {tinykv-0.2.0 → tinykv-0.3.0}/PKG-INFO +21 -25
- {tinykv-0.2.0 → tinykv-0.3.0}/README.md +18 -11
- tinykv-0.3.0/pyproject.toml +68 -0
- tinykv-0.3.0/src/tinykv/__init__.py +504 -0
- tinykv-0.2.0/src/tinykv/__init__.py → tinykv-0.3.0/src/tinykv/__init__.py~ +20 -140
- tinykv-0.2.0/.flake8 +0 -7
- tinykv-0.2.0/.gitignore +0 -3
- tinykv-0.2.0/CHANGELOG.md +0 -58
- tinykv-0.2.0/pyproject.toml +0 -85
- tinykv-0.2.0/tests/__init__.py +0 -4
- tinykv-0.2.0/tests/test_doc.py +0 -16
- tinykv-0.2.0/tests/test_tinykv.py +0 -314
- {tinykv-0.2.0 → tinykv-0.3.0}/LICENSE +0 -0
- {tinykv-0.2.0 → tinykv-0.3.0}/src/tinykv/py.typed +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
Metadata-Version: 2.
|
|
1
|
+
Metadata-Version: 2.5
|
|
2
2
|
Name: tinykv
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 0.3.0
|
|
4
4
|
Summary: A lightweight Python SQLite key-value store built on sqlite3.
|
|
5
5
|
Keywords: python,sqlite,sqlite3,key-value store,kv
|
|
6
6
|
Author-email: Flavio Veloso Soares <flaviovs@magnux.com>
|
|
@@ -11,21 +11,10 @@ Classifier: Programming Language :: Python :: 3
|
|
|
11
11
|
Classifier: Topic :: Database
|
|
12
12
|
Classifier: Topic :: Software Development :: Libraries :: Python Modules
|
|
13
13
|
License-File: LICENSE
|
|
14
|
-
Requires-Dist: codespell ; extra == "dev"
|
|
15
|
-
Requires-Dist: flake8-bugbear ; extra == "dev"
|
|
16
|
-
Requires-Dist: flake8-builtins ; extra == "dev"
|
|
17
|
-
Requires-Dist: flake8-docstrings ; extra == "dev"
|
|
18
|
-
Requires-Dist: flake8-tidy-imports ; extra == "dev"
|
|
19
|
-
Requires-Dist: flake8-walrus ; extra == "dev"
|
|
20
|
-
Requires-Dist: flake8 ; extra == "dev"
|
|
21
|
-
Requires-Dist: flit ; extra == "dev"
|
|
22
|
-
Requires-Dist: mypy ; extra == "dev"
|
|
23
|
-
Requires-Dist: pylint ; extra == "dev"
|
|
24
|
-
Requires-Dist: taskipy ; extra == "dev"
|
|
25
14
|
Project-URL: Homepage, https://github.com/flaviovs/tinykv
|
|
26
15
|
Project-URL: Issues, https://github.com/flaviovs/tinykv/issues
|
|
27
16
|
Project-URL: Repository, https://github.com/flaviovs/tinykv
|
|
28
|
-
|
|
17
|
+
Import-Name: tinykv
|
|
29
18
|
|
|
30
19
|
TinyKV: Python SQLite key-value store
|
|
31
20
|
=====================================
|
|
@@ -93,13 +82,10 @@ Let’s try again:
|
|
|
93
82
|
|
|
94
83
|
Now it works!
|
|
95
84
|
|
|
96
|
-
By default, TinyKV
|
|
97
|
-
serialization/deserialization
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
Applications should not rely on this behavior and should explicitly set
|
|
101
|
-
`allow_pickle=False` when handling databases that might be untrusted.
|
|
102
|
-
The default is expected to change to `False` in a future release.
|
|
85
|
+
By default, TinyKV does not allow pickle-based value
|
|
86
|
+
serialization/deserialization. Applications must explicitly pass
|
|
87
|
+
`allow_pickle=True` to enable it, and should do so only when handling trusted
|
|
88
|
+
database contents.
|
|
103
89
|
|
|
104
90
|
|
|
105
91
|
## Storing and retrieving data
|
|
@@ -153,7 +139,7 @@ Same for container objects:
|
|
|
153
139
|
['one', 'two', 'three']
|
|
154
140
|
|
|
155
141
|
In fact, you can store any pickable object when
|
|
156
|
-
`allow_pickle=True
|
|
142
|
+
`allow_pickle=True`:
|
|
157
143
|
|
|
158
144
|
>>> import datetime
|
|
159
145
|
>>>
|
|
@@ -167,7 +153,8 @@ In fact, you can store any pickable object when
|
|
|
167
153
|
>>> type(a_long_time_ago)
|
|
168
154
|
<class 'datetime.datetime'>
|
|
169
155
|
|
|
170
|
-
|
|
156
|
+
Pickle is disabled by default for safer behavior with untrusted database
|
|
157
|
+
contents:
|
|
171
158
|
|
|
172
159
|
>>> safe_kv = tinykv.TinyKV(conn, allow_pickle=False)
|
|
173
160
|
|
|
@@ -255,6 +242,10 @@ TinyKV requires the database table to exist before use. Create it with
|
|
|
255
242
|
>>> conn = sqlite3.connect(':memory:')
|
|
256
243
|
>>> tinykv.create_schema(conn)
|
|
257
244
|
|
|
245
|
+
If you need idempotent setup, pass `if_not_exists=True`:
|
|
246
|
+
|
|
247
|
+
>>> tinykv.create_schema(conn, if_not_exists=True)
|
|
248
|
+
|
|
258
249
|
You can use a custom table name:
|
|
259
250
|
|
|
260
251
|
>>> tinykv.create_schema(conn, table='my_keys')
|
|
@@ -280,6 +271,9 @@ Miscellaneous
|
|
|
280
271
|
`TypeError`, and empty strings raise `ValueError`. Keys are case-sensitive
|
|
281
272
|
(since v0.1.4).
|
|
282
273
|
|
|
274
|
+
- Keys with the format `__tinykv_XXXXX__` are reserved for TinyKV internal
|
|
275
|
+
use.
|
|
276
|
+
|
|
283
277
|
- TinyKV does not open or manage transactions. Also, it operates both
|
|
284
278
|
in autocommit and non-autocommit mode. All operations are atomic.
|
|
285
279
|
|
|
@@ -306,8 +300,10 @@ Miscellaneous
|
|
|
306
300
|
... allow_pickle=True,
|
|
307
301
|
... )
|
|
308
302
|
|
|
309
|
-
Table names must match the pattern
|
|
310
|
-
|
|
303
|
+
Table names must match the pattern
|
|
304
|
+
`[a-zA-Z_][a-zA-Z0-9_]*(\.[a-zA-Z_][a-zA-Z0-9_]*)?`. The optional prefix
|
|
305
|
+
selects an attached SQLite database, for example `archive.kv`. Each
|
|
306
|
+
identifier is quoted separately. Invalid names raise `ValueError`.
|
|
311
307
|
|
|
312
308
|
|
|
313
309
|
Questions? Bugs? Suggestions?
|
|
@@ -64,13 +64,10 @@ Let’s try again:
|
|
|
64
64
|
|
|
65
65
|
Now it works!
|
|
66
66
|
|
|
67
|
-
By default, TinyKV
|
|
68
|
-
serialization/deserialization
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
Applications should not rely on this behavior and should explicitly set
|
|
72
|
-
`allow_pickle=False` when handling databases that might be untrusted.
|
|
73
|
-
The default is expected to change to `False` in a future release.
|
|
67
|
+
By default, TinyKV does not allow pickle-based value
|
|
68
|
+
serialization/deserialization. Applications must explicitly pass
|
|
69
|
+
`allow_pickle=True` to enable it, and should do so only when handling trusted
|
|
70
|
+
database contents.
|
|
74
71
|
|
|
75
72
|
|
|
76
73
|
## Storing and retrieving data
|
|
@@ -124,7 +121,7 @@ Same for container objects:
|
|
|
124
121
|
['one', 'two', 'three']
|
|
125
122
|
|
|
126
123
|
In fact, you can store any pickable object when
|
|
127
|
-
`allow_pickle=True
|
|
124
|
+
`allow_pickle=True`:
|
|
128
125
|
|
|
129
126
|
>>> import datetime
|
|
130
127
|
>>>
|
|
@@ -138,7 +135,8 @@ In fact, you can store any pickable object when
|
|
|
138
135
|
>>> type(a_long_time_ago)
|
|
139
136
|
<class 'datetime.datetime'>
|
|
140
137
|
|
|
141
|
-
|
|
138
|
+
Pickle is disabled by default for safer behavior with untrusted database
|
|
139
|
+
contents:
|
|
142
140
|
|
|
143
141
|
>>> safe_kv = tinykv.TinyKV(conn, allow_pickle=False)
|
|
144
142
|
|
|
@@ -226,6 +224,10 @@ TinyKV requires the database table to exist before use. Create it with
|
|
|
226
224
|
>>> conn = sqlite3.connect(':memory:')
|
|
227
225
|
>>> tinykv.create_schema(conn)
|
|
228
226
|
|
|
227
|
+
If you need idempotent setup, pass `if_not_exists=True`:
|
|
228
|
+
|
|
229
|
+
>>> tinykv.create_schema(conn, if_not_exists=True)
|
|
230
|
+
|
|
229
231
|
You can use a custom table name:
|
|
230
232
|
|
|
231
233
|
>>> tinykv.create_schema(conn, table='my_keys')
|
|
@@ -251,6 +253,9 @@ Miscellaneous
|
|
|
251
253
|
`TypeError`, and empty strings raise `ValueError`. Keys are case-sensitive
|
|
252
254
|
(since v0.1.4).
|
|
253
255
|
|
|
256
|
+
- Keys with the format `__tinykv_XXXXX__` are reserved for TinyKV internal
|
|
257
|
+
use.
|
|
258
|
+
|
|
254
259
|
- TinyKV does not open or manage transactions. Also, it operates both
|
|
255
260
|
in autocommit and non-autocommit mode. All operations are atomic.
|
|
256
261
|
|
|
@@ -277,8 +282,10 @@ Miscellaneous
|
|
|
277
282
|
... allow_pickle=True,
|
|
278
283
|
... )
|
|
279
284
|
|
|
280
|
-
Table names must match the pattern
|
|
281
|
-
|
|
285
|
+
Table names must match the pattern
|
|
286
|
+
`[a-zA-Z_][a-zA-Z0-9_]*(\.[a-zA-Z_][a-zA-Z0-9_]*)?`. The optional prefix
|
|
287
|
+
selects an attached SQLite database, for example `archive.kv`. Each
|
|
288
|
+
identifier is quoted separately. Invalid names raise `ValueError`.
|
|
282
289
|
|
|
283
290
|
|
|
284
291
|
Questions? Bugs? Suggestions?
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
[build-system]
|
|
2
|
+
requires = ["flit_core >=3.2,<4"]
|
|
3
|
+
build-backend = "flit_core.buildapi"
|
|
4
|
+
|
|
5
|
+
[project]
|
|
6
|
+
name = "tinykv"
|
|
7
|
+
authors = [{name = "Flavio Veloso Soares", email = "flaviovs@magnux.com"}]
|
|
8
|
+
license = {file = "LICENSE"}
|
|
9
|
+
readme = "README.md"
|
|
10
|
+
keywords = ["python", "sqlite", "sqlite3", "key-value store", "kv"]
|
|
11
|
+
classifiers = [
|
|
12
|
+
"License :: OSI Approved :: MIT License",
|
|
13
|
+
"Programming Language :: Python :: 3",
|
|
14
|
+
"Topic :: Database",
|
|
15
|
+
"Topic :: Software Development :: Libraries :: Python Modules",
|
|
16
|
+
]
|
|
17
|
+
requires-python = ">=3.11"
|
|
18
|
+
|
|
19
|
+
dynamic = ["version", "description"]
|
|
20
|
+
|
|
21
|
+
[project.urls]
|
|
22
|
+
Homepage = "https://github.com/flaviovs/tinykv"
|
|
23
|
+
Repository = "https://github.com/flaviovs/tinykv"
|
|
24
|
+
Issues = "https://github.com/flaviovs/tinykv/issues"
|
|
25
|
+
|
|
26
|
+
[dependency-groups]
|
|
27
|
+
dev = [
|
|
28
|
+
'ruff',
|
|
29
|
+
'flit',
|
|
30
|
+
'mypy',
|
|
31
|
+
]
|
|
32
|
+
|
|
33
|
+
[tool.mypy]
|
|
34
|
+
files = "."
|
|
35
|
+
python_version = "3.11"
|
|
36
|
+
exclude = [".git", ".venv"]
|
|
37
|
+
strict = true
|
|
38
|
+
warn_redundant_casts = true
|
|
39
|
+
warn_return_any = true
|
|
40
|
+
warn_unreachable = true
|
|
41
|
+
pretty = true
|
|
42
|
+
|
|
43
|
+
[tool.ruff]
|
|
44
|
+
line-length = 79
|
|
45
|
+
include = ["**/*.py"]
|
|
46
|
+
|
|
47
|
+
[tool.ruff.format]
|
|
48
|
+
skip-magic-trailing-comma = false
|
|
49
|
+
|
|
50
|
+
[tool.ruff.lint]
|
|
51
|
+
extend-select = ["PLC0415"]
|
|
52
|
+
external = ["V107"]
|
|
53
|
+
select = [
|
|
54
|
+
"E", "F", "I", "B", "UP", "SIM", "RET", "ARG", "RUF", "PTH", "C4", "PIE", "D",
|
|
55
|
+
"TRY", "ERA", "ANN",
|
|
56
|
+
]
|
|
57
|
+
ignore = ["TRY003", "COM812"]
|
|
58
|
+
|
|
59
|
+
[tool.ruff.lint.per-file-ignores]
|
|
60
|
+
"tests/**" = ["D"]
|
|
61
|
+
|
|
62
|
+
[tool.ruff.lint.isort]
|
|
63
|
+
combine-as-imports = true
|
|
64
|
+
known-first-party = ["traderworkbench"]
|
|
65
|
+
|
|
66
|
+
[tool.ruff.lint.pydocstyle]
|
|
67
|
+
# Explicitly enforce Google-style docstrings instead of PEP 257 standard.
|
|
68
|
+
convention = "google"
|