Skip to main content

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-dic lets 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, and None without 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, or None).
  • Concurrent writes are serialized by SQLite's file lock (busy timeout: 30 seconds).

Metadata

Release files for sqlite-dic 0.0.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for sqlite-dic 0.0.1
File Size Uploaded Provenance
sqlite_dic-0.0.1.tar.gz 4.5 kB Without provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for sqlite-dic 0.0.1
File Interpreter ABI Platform
sqlite_dic-0.0.1-py3-none-any.whl Python 3 none any Details

Total release size: 9.2 kB

Release files / sqlite_dic-0.0.1.tar.gz

Download URL sqlite_dic-0.0.1.tar.gz
Size 4.5 kB
Tags Source
SHA-256 checksum
How to use checksums
45698d2f2d7d39e68d690d83c27eab337c8ad261c3fc8e383bfce993d32f40e2
BLAKE2b-256 checksum
How to use checksums
ab8812ddddb6e0f200a2d0d0b8cae231134d10146536d872aeb747c87d678e49
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.1.1 CPython/3.11.3

Release files / sqlite_dic-0.0.1-py3-none-any.whl

Download URL sqlite_dic-0.0.1-py3-none-any.whl
Size 4.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
15baf4b8428be04379316950d0153b038ad0e11c6427b0c8ca6d5da6c87ab111
BLAKE2b-256 checksum
How to use checksums
bf79af683e3c12644895e08ff8294fc067122085853ffb20492a7fb0c3b0e8c1
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.1.1 CPython/3.11.3

Security for sqlite-dic 0.0.1

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.0.1 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page