English description follows Japanese.
Pythonの辞書のように使える、SQLiteバックエンドの軽量キーバリューストアです。
概要
sqlite-dicは、SQLiteデータベースをPythonの辞書と同じ感覚で操作できるライブラリです。値にはJSONシリアライズ可能な任意の型(文字列、数値、真偽値、リスト、辞書、None)を格納できます。- 内部ではSQLiteのWAL(Write-Ahead Logging)モードを使用しており、読み書きの並列アクセスが可能です。すべての操作はスレッドセーフです。
インストール
pip install sqlite-dic
使い方
import sqlite_dic
# データベースを開く(存在しなければ自動作成)
db = sqlite_dic("./sample.db")
# 値の追加・更新 — 辞書と同じ書き方
db["count"] = 33
db["config"] = {"theme": "dark", "lang": "ja"}
# 値の取得
print(db["count"]) # 33
print(db["config"]) # {'theme': 'dark', 'lang': 'ja'}
# エントリの削除
del db["count"]
# 格納数の確認
print(len(db)) # 1
制約
- キー は文字列のみ使用可能です。
- 値 はJSONシリアライズ可能な型(
dict、list、str、int、float、bool、None)に限ります。 - 同時書き込みはSQLiteのファイルロックにより直列化されます(busy timeout: 30秒)。
AIコーディング向けの説明
AIコーディングにおいてこのツールを使用するときは、下記をプロンプトに含めることで、AIにこのDBを使ってコーディングしてもらうことが可能です。
sqlite-dicはPyPIにあるDBツールで、Pythonの辞書のように使える、SQLiteバックエンドの軽量キーバリューストアです。
`pip install slim-id` でインストール可能です。
## 概要
- `sqlite-dic` は、SQLiteデータベースをPythonの辞書と同じ感覚で操作できるライブラリです。値にはJSONシリアライズ可能な任意の型(文字列、数値、真偽値、リスト、辞書、`None`)を格納できます。
- 内部ではSQLiteのWAL(Write-Ahead Logging)モードを使用しており、読み書きの並列アクセスが可能です。すべての操作はスレッドセーフです。
## 使い方
import sqlite_dic
db = sqlite_dic("./sample.db") # データベースを開く(存在しなければ自動作成)
db["count"] = 33 # 値の追加・更新 — 辞書と同じ書き方
db["config"] = {"theme": "dark", "lang": "ja"}
print(db["count"]) # -> 33
print(db["config"]) # -> {'theme': 'dark', 'lang': 'ja'}
del db["count"] # エントリの削除
print(len(db)) # -> 1
## 制約
- **キー** は文字列のみ使用可能です。
- **値** はJSONシリアライズ可能な型(`dict`、`list`、`str`、`int`、`float`、`bool`、`None`)に限ります。
- 同時書き込みはSQLiteのファイルロックにより直列化されます(busy timeout: 30秒)。
A lightweight key-value store backed by SQLite, with a Python dict-like interface.
Overview
sqlite-diclets you use an SQLite database as if it were a regular Python dictionary. Values can be any JSON-serializable type, so you can store strings, numbers, booleans, lists, dicts, andNonewithout any extra setup.- Under the hood, SQLite's WAL (Write-Ahead Logging) mode provides concurrent read/write access, and all operations are thread-safe.
Installation
pip install sqlite-dic
Quick Start
import sqlite_dic
# Open (or create) a database
db = sqlite_dic("./sample.db")
# Set values — just like a dict
db["count"] = 33
db["config"] = {"theme": "dark", "lang": "en"}
# Get values
print(db["count"]) # 33
print(db["config"]) # {'theme': 'dark', 'lang': 'en'}
# Delete an entry
del db["count"]
# Check the number of stored entries
print(len(db)) # 1
Constraints
- Keys must be strings.
- Values must be JSON-serializable (
dict,list,str,int,float,bool, orNone). - Concurrent writes are serialized by SQLite's file lock (busy timeout: 30 seconds).
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
sqlite_dic-0.0.1.tar.gz
(4.5 kB
view details)
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file sqlite_dic-0.0.1.tar.gz.
File metadata
- Download URL: sqlite_dic-0.0.1.tar.gz
- Upload date:
- Size: 4.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via:
twine/5.1.1 CPython/3.11.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
45698d2f2d7d39e68d690d83c27eab337c8ad261c3fc8e383bfce993d32f40e2
|
|
| MD5 |
d166bb7e91a0d0712b1d22dcd9ec5892
|
|
| BLAKE2b-256 |
ab8812ddddb6e0f200a2d0d0b8cae231134d10146536d872aeb747c87d678e49
|
File details
Details for the file sqlite_dic-0.0.1-py3-none-any.whl.
File metadata
- Download URL: sqlite_dic-0.0.1-py3-none-any.whl
- Upload date:
- Size: 4.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via:
twine/5.1.1 CPython/3.11.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
15baf4b8428be04379316950d0153b038ad0e11c6427b0c8ca6d5da6c87ab111
|
|
| MD5 |
6619840a5fa80005094cd14493f2f58e
|
|
| BLAKE2b-256 |
bf79af683e3c12644895e08ff8294fc067122085853ffb20492a7fb0c3b0e8c1
|