tinykv 0.2.1__tar.gz → 0.4.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.
@@ -1,6 +1,6 @@
1
- Metadata-Version: 2.4
1
+ Metadata-Version: 2.5
2
2
  Name: tinykv
3
- Version: 0.2.1
3
+ Version: 0.4.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
- Provides-Extra: dev
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 currently allows pickle-based value
97
- serialization/deserialization for compatibility.
98
- If `allow_pickle` is omitted, TinyKV currently behaves as if
99
- `allow_pickle=True` and emits a `FutureWarning`.
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
@@ -111,6 +97,21 @@ database, respectively:
111
97
  >>> kv.get('foo')
112
98
  'bar'
113
99
 
100
+ Use `inc()`, `dec()`, and `add()` to update integer counters atomically:
101
+
102
+ >>> kv.inc('visits')
103
+ 1
104
+ >>> kv.inc('visits', 2)
105
+ 3
106
+ >>> kv.dec('visits')
107
+ 2
108
+ >>> kv.add('visits', -5)
109
+ -3
110
+
111
+ Missing keys start at zero. Amounts must be integers (not booleans), and
112
+ `inc()` and `dec()` require nonnegative amounts. An existing value must be an
113
+ integer; otherwise the operation raises `TypeError`.
114
+
114
115
  Trying to get a nonexistent key raises _KeyError_:
115
116
 
116
117
  >>> kv.get('not-there')
@@ -153,7 +154,7 @@ Same for container objects:
153
154
  ['one', 'two', 'three']
154
155
 
155
156
  In fact, you can store any pickable object when
156
- `allow_pickle=True` (the current default):
157
+ `allow_pickle=True`:
157
158
 
158
159
  >>> import datetime
159
160
  >>>
@@ -167,7 +168,8 @@ In fact, you can store any pickable object when
167
168
  >>> type(a_long_time_ago)
168
169
  <class 'datetime.datetime'>
169
170
 
170
- For safer behavior with untrusted database contents, disable pickle:
171
+ Pickle is disabled by default for safer behavior with untrusted database
172
+ contents:
171
173
 
172
174
  >>> safe_kv = tinykv.TinyKV(conn, allow_pickle=False)
173
175
 
@@ -284,6 +286,9 @@ Miscellaneous
284
286
  `TypeError`, and empty strings raise `ValueError`. Keys are case-sensitive
285
287
  (since v0.1.4).
286
288
 
289
+ - Keys with the format `__tinykv_XXXXX__` are reserved for TinyKV internal
290
+ use.
291
+
287
292
  - TinyKV does not open or manage transactions. Also, it operates both
288
293
  in autocommit and non-autocommit mode. All operations are atomic.
289
294
 
@@ -310,8 +315,10 @@ Miscellaneous
310
315
  ... allow_pickle=True,
311
316
  ... )
312
317
 
313
- Table names must match the pattern `[a-zA-Z_][a-zA-Z0-9_]*`. Invalid
314
- names raise `ValueError`.
318
+ Table names must match the pattern
319
+ `[a-zA-Z_][a-zA-Z0-9_]*(\.[a-zA-Z_][a-zA-Z0-9_]*)?`. The optional prefix
320
+ selects an attached SQLite database, for example `archive.kv`. Each
321
+ identifier is quoted separately. Invalid names raise `ValueError`.
315
322
 
316
323
 
317
324
  Questions? Bugs? Suggestions?
@@ -64,13 +64,10 @@ Let’s try again:
64
64
 
65
65
  Now it works!
66
66
 
67
- By default, TinyKV currently allows pickle-based value
68
- serialization/deserialization for compatibility.
69
- If `allow_pickle` is omitted, TinyKV currently behaves as if
70
- `allow_pickle=True` and emits a `FutureWarning`.
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
@@ -82,6 +79,21 @@ database, respectively:
82
79
  >>> kv.get('foo')
83
80
  'bar'
84
81
 
82
+ Use `inc()`, `dec()`, and `add()` to update integer counters atomically:
83
+
84
+ >>> kv.inc('visits')
85
+ 1
86
+ >>> kv.inc('visits', 2)
87
+ 3
88
+ >>> kv.dec('visits')
89
+ 2
90
+ >>> kv.add('visits', -5)
91
+ -3
92
+
93
+ Missing keys start at zero. Amounts must be integers (not booleans), and
94
+ `inc()` and `dec()` require nonnegative amounts. An existing value must be an
95
+ integer; otherwise the operation raises `TypeError`.
96
+
85
97
  Trying to get a nonexistent key raises _KeyError_:
86
98
 
87
99
  >>> kv.get('not-there')
@@ -124,7 +136,7 @@ Same for container objects:
124
136
  ['one', 'two', 'three']
125
137
 
126
138
  In fact, you can store any pickable object when
127
- `allow_pickle=True` (the current default):
139
+ `allow_pickle=True`:
128
140
 
129
141
  >>> import datetime
130
142
  >>>
@@ -138,7 +150,8 @@ In fact, you can store any pickable object when
138
150
  >>> type(a_long_time_ago)
139
151
  <class 'datetime.datetime'>
140
152
 
141
- For safer behavior with untrusted database contents, disable pickle:
153
+ Pickle is disabled by default for safer behavior with untrusted database
154
+ contents:
142
155
 
143
156
  >>> safe_kv = tinykv.TinyKV(conn, allow_pickle=False)
144
157
 
@@ -255,6 +268,9 @@ Miscellaneous
255
268
  `TypeError`, and empty strings raise `ValueError`. Keys are case-sensitive
256
269
  (since v0.1.4).
257
270
 
271
+ - Keys with the format `__tinykv_XXXXX__` are reserved for TinyKV internal
272
+ use.
273
+
258
274
  - TinyKV does not open or manage transactions. Also, it operates both
259
275
  in autocommit and non-autocommit mode. All operations are atomic.
260
276
 
@@ -281,8 +297,10 @@ Miscellaneous
281
297
  ... allow_pickle=True,
282
298
  ... )
283
299
 
284
- Table names must match the pattern `[a-zA-Z_][a-zA-Z0-9_]*`. Invalid
285
- names raise `ValueError`.
300
+ Table names must match the pattern
301
+ `[a-zA-Z_][a-zA-Z0-9_]*(\.[a-zA-Z_][a-zA-Z0-9_]*)?`. The optional prefix
302
+ selects an attached SQLite database, for example `archive.kv`. Each
303
+ identifier is quoted separately. Invalid names raise `ValueError`.
286
304
 
287
305
 
288
306
  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"