nanasqlite 1.3.3.dev4__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.
@@ -0,0 +1,413 @@
1
+ Metadata-Version: 2.4
2
+ Name: nanasqlite
3
+ Version: 1.3.3.dev4
4
+ Summary: A dict-like SQLite wrapper with APSW for instant persistence and memory caching
5
+ Author-email: Disnana <support@disnana.com>
6
+ License-Expression: MIT
7
+ Project-URL: Homepage, https://github.com/disnana/nanasqlite
8
+ Project-URL: Documentation, https://nanasqlite.disnana.com/
9
+ Project-URL: Repository, https://github.com/disnana/nanasqlite
10
+ Project-URL: Issues, https://github.com/disnana/nanasqlite/issues
11
+ Keywords: sqlite,apsw,dict,database,persistence,cache,key-value,nosql
12
+ Classifier: Development Status :: 5 - Production/Stable
13
+ Classifier: Intended Audience :: Developers
14
+ Classifier: Operating System :: OS Independent
15
+ Classifier: Programming Language :: Python :: 3
16
+ Classifier: Programming Language :: Python :: 3.9
17
+ Classifier: Programming Language :: Python :: 3.10
18
+ Classifier: Programming Language :: Python :: 3.11
19
+ Classifier: Programming Language :: Python :: 3.12
20
+ Classifier: Programming Language :: Python :: 3.13
21
+ Classifier: Programming Language :: Python :: 3.14
22
+ Classifier: Topic :: Database
23
+ Classifier: Topic :: Software Development :: Libraries :: Python Modules
24
+ Classifier: Typing :: Typed
25
+ Requires-Python: >=3.9
26
+ Description-Content-Type: text/markdown
27
+ License-File: LICENSE
28
+ Requires-Dist: apsw>=3.40.0.0
29
+ Provides-Extra: speed
30
+ Requires-Dist: lru-dict>=1.3.0; extra == "speed"
31
+ Requires-Dist: orjson>=3.9.10; extra == "speed"
32
+ Provides-Extra: encryption
33
+ Requires-Dist: cryptography>=42.0.0; extra == "encryption"
34
+ Provides-Extra: dev
35
+ Requires-Dist: pytest>=7.0.0; extra == "dev"
36
+ Requires-Dist: pytest-cov>=4.0.0; extra == "dev"
37
+ Requires-Dist: pytest-asyncio<2.0.0,>=0.21.0; extra == "dev"
38
+ Requires-Dist: pydantic>=2.0.0; extra == "dev"
39
+ Requires-Dist: tox>=4.0.0; extra == "dev"
40
+ Requires-Dist: ruff>=0.8.0; extra == "dev"
41
+ Requires-Dist: mypy>=1.13.0; extra == "dev"
42
+ Requires-Dist: pytest-xdist>=3.0.0; extra == "dev"
43
+ Requires-Dist: pytest-benchmark>=4.0.0; extra == "dev"
44
+ Provides-Extra: all
45
+ Requires-Dist: lru-dict>=1.3.0; extra == "all"
46
+ Requires-Dist: orjson>=3.9.10; extra == "all"
47
+ Requires-Dist: cryptography>=42.0.0; extra == "all"
48
+ Dynamic: license-file
49
+
50
+ # NanaSQLite
51
+
52
+ [![PyPI version](https://img.shields.io/pypi/v/nanasqlite.svg)](https://pypi.org/project/nanasqlite/)
53
+ [![Python versions](https://img.shields.io/pypi/pyversions/nanasqlite.svg)](https://pypi.org/project/nanasqlite/)
54
+ [![License: MIT](https://img.shields.io/badge/License-MIT-blue.svg)](https://opensource.org/licenses/MIT)
55
+ [![Downloads](https://static.pepy.tech/badge/nanasqlite)](https://pepy.tech/project/nanasqlite)
56
+ [![Tests](https://github.com/disnana/nanasqlite/actions/workflows/ci.yml/badge.svg)](https://github.com/disnana/nanasqlite/actions/workflows/ci.yml)
57
+
58
+ **A dict-like SQLite wrapper with instant persistence and intelligent caching.**
59
+
60
+ [English](#english) | [日本語](#日本語)
61
+
62
+ ---
63
+
64
+ ## English
65
+
66
+ ### 🚀 Features
67
+
68
+ - **Dict-like Interface**: Use familiar `db["key"] = value` syntax
69
+ - **Instant Persistence**: All writes are immediately saved to SQLite
70
+ - **Smart Caching**: Lazy load (on-access) or bulk load (all at once)
71
+ - **Nested Structures**: Full support for nested dicts and lists (up to 30+ levels)
72
+ - **High Performance**: WAL mode, mmap, and batch operations for maximum speed
73
+ - **Security & Stability (v1.2.0)**: SQL validation, ReDoS protection, and strict connection management
74
+ - **Zero Configuration**: Works out of the box with sensible defaults
75
+
76
+ ### 📦 Installation
77
+
78
+ ```bash
79
+ pip install nanasqlite
80
+ ```
81
+
82
+ Optional installation extras:
83
+
84
+ ```bash
85
+ # Performance boosters (orjson + lru-dict)
86
+ pip install "nanasqlite[speed]"
87
+
88
+ # Enable encryption features (AES-GCM/ChaCha20/Fernet)
89
+ pip install "nanasqlite[encryption]"
90
+
91
+ # Install all optional runtime features
92
+ pip install "nanasqlite[all]"
93
+
94
+ # Development tools (pytest, ruff, mypy, tox, etc.)
95
+ pip install -e ".[dev]"
96
+ ```
97
+
98
+ ### ⚡ Quick Start
99
+
100
+ ```python
101
+ from nanasqlite import NanaSQLite
102
+
103
+ # Create or open a database
104
+ db = NanaSQLite("mydata.db")
105
+
106
+ # Use it like a dict
107
+ db["user"] = {"name": "Nana", "age": 20, "tags": ["admin", "active"]}
108
+ print(db["user"]) # {'name': 'Nana', 'age': 20, 'tags': ['admin', 'active']}
109
+
110
+ # Data persists automatically
111
+ db.close()
112
+
113
+ # Reopen later - data is still there!
114
+ db = NanaSQLite("mydata.db")
115
+ print(db["user"]["name"]) # 'Nana'
116
+ ```
117
+
118
+ ### 🔧 Advanced Usage
119
+
120
+ ```python
121
+ # Bulk load for faster repeated access
122
+ db = NanaSQLite("mydata.db", bulk_load=True)
123
+
124
+ # Batch operations for high-speed reads/writes
125
+ db.batch_update({"k1": "v1", "k2": "v2"})
126
+ results = db.batch_get(["k1", "k2"])
127
+
128
+ # Context manager support
129
+ with NanaSQLite("mydata.db") as db:
130
+ db["temp"] = "value"
131
+ ```
132
+
133
+ ### 📚 Documentation
134
+
135
+ - **[Official Documentation Website ↗](https://nanasqlite.disnana.com/)** (Best Experience)
136
+ - [English Guide](https://nanasqlite.disnana.com/en/guide)
137
+ - [API Reference (Sync)](https://nanasqlite.disnana.com/en/api_sync)
138
+ - [API Reference (Async)](https://nanasqlite.disnana.com/en/api_async)
139
+ - [Benchmark Trends 📊](https://nanasqlite.disnana.com/dev/bench/)
140
+ - [Migration Guide (v1.1.x to v1.2.0)](MIGRATION_GUIDE.md)
141
+
142
+ ### ✨ v1.3.x New Features
143
+
144
+ - **Advanced Cache Strategies**: LRU and TTL support. [Learn more](https://nanasqlite.disnana.com/en/guide#lesson-10-cache-strategies)
145
+ - **Data Encryption**: Secure storage with AES-GCM (default), ChaCha20, or Fernet. [Learn more](https://nanasqlite.disnana.com/en/guide#lesson-11-encryption)
146
+ - **Persistence TTL**: Self-expiring data for sessions and temporary storage.
147
+
148
+ ### ✨ v1.2.0 New Features
149
+
150
+ **Security Enhancements & Strict Connection Management:**
151
+
152
+ ```python
153
+ # v1.2.0 Security Features
154
+ db = NanaSQLite("mydata.db",
155
+ strict_sql_validation=True, # Disallow unauthorized SQL functions
156
+ max_clause_length=500 # Limit SQL length to prevent ReDoS
157
+ )
158
+
159
+ # v1.2.0 Read-Only Connection Pool (Async only)
160
+ async with AsyncNanaSQLite("mydata.db", read_pool_size=5) as db:
161
+ # Heavy read operations (query, fetch_all) use the pool automatically
162
+ # allowing parallel execution without blocking writes or other reads
163
+ results = await asyncio.gather(
164
+ db.query("logs", where="level=?", parameters=("ERROR",)),
165
+ db.query("logs", where="level=?", parameters=("INFO",)),
166
+ db.query("logs", where="level=?", parameters=("WARN",))
167
+ )
168
+
169
+ # Strict Connection Management
170
+ with db.transaction():
171
+ sub_db = db.table("sub")
172
+ # ... operations ...
173
+ db.close()
174
+ # Accessing sub_db now raises NanaSQLiteClosedError for safety!
175
+ ```
176
+
177
+ **[Read Secure Development Guide ↗](https://nanasqlite.disnana.com/en/guide#_2-security-v1-2-0-)**
178
+
179
+ ### ✨ v1.1.0 New Features
180
+
181
+ **Safely operate multiple tables in the same database with shared connections:**
182
+
183
+ ```python
184
+ from nanasqlite import NanaSQLite
185
+
186
+ # Create main table instance
187
+ main_db = NanaSQLite("mydata.db", table="users")
188
+
189
+ # Get another table instance sharing the same connection
190
+ products_db = main_db.table("products")
191
+ orders_db = main_db.table("orders")
192
+
193
+ # Each table has isolated cache and operations
194
+ main_db["user1"] = {"name": "Alice", "email": "alice@example.com"}
195
+ products_db["prod1"] = {"name": "Laptop", "price": 999}
196
+ orders_db["order1"] = {"user": "user1", "product": "prod1"}
197
+ ```
198
+
199
+
200
+ **Transaction Support & Error Handling (v1.1.0+):**
201
+
202
+ ```python
203
+ from nanasqlite import NanaSQLite, NanaSQLiteTransactionError
204
+
205
+ with db.transaction():
206
+ db["key1"] = "value1"
207
+ db["key2"] = "value2"
208
+ ```
209
+
210
+ **[Explore Multi-table & Transactions ↗](https://nanasqlite.disnana.com/en/guide#_4-transactions-multi-table)**
211
+
212
+ ### ✨ v1.0.3+ Legacy Features
213
+
214
+ **Pydantic Support & Direct SQL:**
215
+
216
+ ```python
217
+ # Pydantic support
218
+ db.set_model("user", User(name="Nana", age=20))
219
+
220
+ # Direct SQL execution
221
+ db.execute("SELECT * FROM data WHERE key LIKE ?", ("user%",))
222
+
223
+ # 22 new SQLite wrapper functions (sql_insert, sql_update, count, etc.)
224
+ db.sql_insert("users", {"name": "Alice", "age": 25})
225
+ ```
226
+
227
+ ---
228
+
229
+ ---
230
+
231
+ ---
232
+
233
+ ## 日本語
234
+
235
+ ### 🚀 特徴
236
+
237
+ - **dict風インターフェース**: おなじみの `db["key"] = value` 構文で操作
238
+ - **即時永続化**: 書き込みは即座にSQLiteに保存
239
+ - **スマートキャッシュ**: 遅延ロード(アクセス時)または一括ロード(起動時)
240
+ - **ネスト構造対応**: 30階層以上のネストしたdict/listをサポート
241
+ - **高性能**: WALモード、mmap、バッチ操作で最高速度を実現
242
+ - **セキュリティと安定性 (v1.2.0)**: SQL検証、ReDoS対策、厳格な接続管理を導入
243
+ - **設定不要**: 合理的なデフォルト設定でそのまま動作
244
+
245
+ ### 📦 インストール
246
+
247
+ ```bash
248
+ pip install nanasqlite
249
+ ```
250
+
251
+ オプション機能付きのインストール:
252
+
253
+ ```bash
254
+ # 高速化オプション(orjson + lru-dict)
255
+ pip install "nanasqlite[speed]"
256
+
257
+ # 暗号化機能(AES-GCM/ChaCha20/Fernet)
258
+ pip install "nanasqlite[encryption]"
259
+
260
+ # すべてのランタイム用オプションを一括インストール
261
+ pip install "nanasqlite[all]"
262
+
263
+ # 開発用ツール(pytest, ruff, mypy, tox等)
264
+ pip install -e ".[dev]"
265
+ ```
266
+
267
+ ### ⚡ クイックスタート
268
+
269
+ ```python
270
+ from nanasqlite import NanaSQLite
271
+
272
+ # データベースを作成または開く
273
+ db = NanaSQLite("mydata.db")
274
+
275
+ # dictのように使う
276
+ db["user"] = {"name": "Nana", "age": 20, "tags": ["admin", "active"]}
277
+ print(db["user"]) # {'name': 'Nana', 'age': 20, 'tags': ['admin', 'active']}
278
+
279
+ # データは自動的に永続化
280
+ db.close()
281
+
282
+ # 後で再度開いても、データはそのまま!
283
+ db = NanaSQLite("mydata.db")
284
+ print(db["user"]["name"]) # 'Nana'
285
+ ```
286
+
287
+ ### 🔧 高度な使い方
288
+
289
+ ```python
290
+ # 一括ロードで繰り返しアクセスを高速化
291
+ db = NanaSQLite("mydata.db", bulk_load=True)
292
+
293
+ # バッチ操作で高速な読み書き
294
+ db.batch_update({"k1": "v1", "k2": "v2"})
295
+ results = db.batch_get(["k1", "k2"])
296
+
297
+ # コンテキストマネージャ対応
298
+ with NanaSQLite("mydata.db") as db:
299
+ db["temp"] = "value"
300
+ ```
301
+
302
+ ### 📚 ドキュメント
303
+
304
+ - **[公式サイト ↗](https://nanasqlite.disnana.com/)** (推奨)
305
+ - [スタートアップガイド](https://nanasqlite.disnana.com/guide)
306
+ - [APIリファレンス (同期)](https://nanasqlite.disnana.com/api_sync)
307
+ - [APIリファレンス (非同期)](https://nanasqlite.disnana.com/api_async)
308
+ - [ベンチマーク履歴 📊](https://nanasqlite.disnana.com/dev/bench/)
309
+ - [移行ガイド (v1.1.x から v1.2.0)](MIGRATION_GUIDE.md)
310
+
311
+ ### ✨ v1.3.x 新機能
312
+
313
+ - **キャッシュ戦略**: LRU / TTL サポート ([ドキュメント](https://nanasqlite.disnana.com/guide#lesson-10-キャッシュ戦略))
314
+ - **データ暗号化**: AES-GCM / ChaCha20 / Fernet ([ドキュメント](https://nanasqlite.disnana.com/guide#lesson-11-暗号化))
315
+ - **永続化 TTL**: SQLite上のデータの自動消去。
316
+
317
+ ### ✨ v1.2.0 新機能
318
+
319
+ **セキュリティ強化と厳格な接続管理:**
320
+
321
+ ```python
322
+ # v1.2.0 セキュリティ機能
323
+ db = NanaSQLite("mydata.db",
324
+ strict_sql_validation=True, # 未許可のSQL関数を禁止
325
+ max_clause_length=500 # SQLの長さを制限してReDoSを防止
326
+ )
327
+
328
+ # v1.2.0 読み取り専用接続プール(非同期のみ)
329
+ async with AsyncNanaSQLite("mydata.db", read_pool_size=5) as db:
330
+ # 重い読み取り操作(query, fetch_all)は自動的にプールを使用
331
+ results = await asyncio.gather(
332
+ db.query("logs", where="level=?", parameters=("ERROR",)),
333
+ db.query("logs", where="level=?", parameters=("INFO",))
334
+ )
335
+
336
+ # 厳格な接続管理
337
+ db.close()
338
+ # 無効化されたインスタンスへのアクセスは NanaSQLiteClosedError を送出します。
339
+ ```
340
+
341
+ **[セキュリティ詳細を見る ↗](https://nanasqlite.disnana.com/guide#_2-強力なセキュリティ-v1-2-0-)**
342
+
343
+ ### ✨ v1.1.0 新機能
344
+
345
+ **同一データベース内の複数テーブルを接続共有で安全に操作:**
346
+
347
+ ```python
348
+ from nanasqlite import NanaSQLite
349
+
350
+ # メインテーブルインスタンスを作成
351
+ main_db = NanaSQLite("mydata.db", table="users")
352
+
353
+ # 同じ接続を共有する別のテーブルインスタンスを取得
354
+ products_db = main_db.table("products")
355
+ orders_db = main_db.table("orders")
356
+
357
+ # 各テーブルは独立したキャッシュと操作を持つ
358
+ main_db["user1"] = {"name": "Alice"}
359
+ products_db["prod1"] = {"name": "Laptop"}
360
+ ```
361
+
362
+ **オプションのデータ暗号化 (v1.3.1a1+):**
363
+
364
+ ```python
365
+ from nanasqlite import NanaSQLite
366
+
367
+ # 事前にインストール: pip install nanasqlite[encryption]
368
+ db = NanaSQLite("secure.db", encryption_key=b"your-32-byte-key") # デフォルトで AES-GCM
369
+
370
+ # モードを明示的に指定する場合
371
+ db_chacha = NanaSQLite("secure_cc.db",
372
+ encryption_key=b"your-32-byte-key",
373
+ encryption_mode="chacha20"
374
+ )
375
+
376
+ # SQLite内では暗号化されますが、メモリ上(キャッシュ)では平文で高速に扱えます
377
+ db["secret"] = {"password": "123"}
378
+ ```
379
+
380
+ **トランザクションサポートとエラーハンドリング (v1.1.0+):**
381
+
382
+ ```python
383
+ from nanasqlite import NanaSQLite, NanaSQLiteTransactionError
384
+
385
+ with db.transaction():
386
+ db["key1"] = "value1"
387
+ db["key2"] = "value2"
388
+ ```
389
+
390
+ **[マルチテーブルと非同期を詳しく ↗](https://nanasqlite.disnana.com/guide#_4-トランザクションとマルチテーブル)**
391
+
392
+ ### ✨ v1.0.3+ レガシー機能
393
+
394
+ **Pydantic互換性と直接SQL実行:**
395
+
396
+ ```python
397
+ # Pydantic互換性
398
+ db.set_model("user", User(name="Nana", age=20))
399
+
400
+ # 直接SQL実行
401
+ db.execute("SELECT * FROM data WHERE key LIKE ?", ("user%",))
402
+
403
+ # 22種類のSQLiteラッパー関数 (sql_insert, sql_update, count等)
404
+ db.sql_insert("users", {"name": "Alice", "age": 25})
405
+ ```
406
+
407
+ ---
408
+
409
+ ---
410
+
411
+ ## License
412
+
413
+ MIT License - see [LICENSE](LICENSE) for details.
@@ -0,0 +1,13 @@
1
+ nanasqlite/__init__.py,sha256=tAbfhOJSaYuny4XPSEb4xhlfEENCkwXfrKJZg0im0fw,1357
2
+ nanasqlite/async_core.py,sha256=WniREZJMG0_2JjSJ6E06qN5JlFcHh8f71Uqiq32vCZw,52991
3
+ nanasqlite/cache.py,sha256=RN4B8O3Jxjl3VD7Bu8JLLBRQavR5maAOxE2MF71Uywg,9656
4
+ nanasqlite/core.py,sha256=-nw_pPV1DqiQHkMCDSRnBXWK0FKdk9U3u8Si1rfFhkg,87414
5
+ nanasqlite/exceptions.py,sha256=ynq0dr4m7V1p1BJL1pzGjy0JAU76QIMH0obBG7V-dsc,2769
6
+ nanasqlite/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
7
+ nanasqlite/sql_utils.py,sha256=RpK8ECp1xl55dkZe5W3AzHzUxoOKPxy28Xc-tP_5_s4,5214
8
+ nanasqlite/utils.py,sha256=IUMqj7pedmzoBiXhZHy3QVpMt6HZ-D_9qExRUrKmy98,7598
9
+ nanasqlite-1.3.3.dev4.dist-info/licenses/LICENSE,sha256=FZXVoQyFIM3OV53_ruGcUkvM1T21CSypHYGYXZr90nA,1064
10
+ nanasqlite-1.3.3.dev4.dist-info/METADATA,sha256=StWVKBZhYW2MDWY8y79Rnt4iA7B0vBBzcAdJhaFAR28,13612
11
+ nanasqlite-1.3.3.dev4.dist-info/WHEEL,sha256=qELbo2s1Yzl39ZmrAibXA2jjPLUYfnVhUNTlyF1rq0Y,92
12
+ nanasqlite-1.3.3.dev4.dist-info/top_level.txt,sha256=fMNj_CZYAve9QSdBq8eRIT4YHszYO88NNrIyrbNdffQ,11
13
+ nanasqlite-1.3.3.dev4.dist-info/RECORD,,
@@ -0,0 +1,5 @@
1
+ Wheel-Version: 1.0
2
+ Generator: setuptools (80.10.1)
3
+ Root-Is-Purelib: true
4
+ Tag: py3-none-any
5
+
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2024 Disnana
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1 @@
1
+ nanasqlite