Skip to main content

A dict-like SQLite wrapper with APSW for instant persistence and memory caching

Project description

NanaSQLite

PyPI version Tests Python 3.9+ License: MIT

A dict-like SQLite wrapper with instant persistence and intelligent caching.

English | 日本語


English

🚀 Features

  • Dict-like Interface: Use familiar db["key"] = value syntax
  • Instant Persistence: All writes are immediately saved to SQLite
  • Smart Caching: Lazy load (on-access) or bulk load (all at once)
  • Nested Structures: Full support for nested dicts and lists (up to 30+ levels)
  • High Performance: WAL mode, mmap, and batch operations for maximum speed
  • Zero Configuration: Works out of the box with sensible defaults

📦 Installation

pip install nanasqlite

⚡ Quick Start

from nanasqlite import NanaSQLite

# Create or open a database
db = NanaSQLite("mydata.db")

# Use it like a dict
db["user"] = {"name": "Nana", "age": 20, "tags": ["admin", "active"]}
print(db["user"])  # {'name': 'Nana', 'age': 20, 'tags': ['admin', 'active']}

# Data persists automatically
db.close()

# Reopen later - data is still there!
db = NanaSQLite("mydata.db")
print(db["user"]["name"])  # 'Nana'

🔧 Advanced Usage

# Bulk load for faster repeated access
db = NanaSQLite("mydata.db", bulk_load=True)

# Batch operations for high-speed writes
db.batch_update({
    "key1": "value1",
    "key2": "value2",
    "key3": {"nested": "data"}
})

# Context manager support
with NanaSQLite("mydata.db") as db:
    db["temp"] = "value"

📚 Documentation


日本語

🚀 特徴

  • dict風インターフェース: おなじみの db["key"] = value 構文で操作
  • 即時永続化: 書き込みは即座にSQLiteに保存
  • スマートキャッシュ: 遅延ロード(アクセス時)または一括ロード(起動時)
  • ネスト構造対応: 30階層以上のネストしたdict/listをサポート
  • 高性能: WALモード、mmap、バッチ操作で最高速度を実現
  • 設定不要: 合理的なデフォルト設定でそのまま動作

📦 インストール

pip install nanasqlite

⚡ クイックスタート

from nanasqlite import NanaSQLite

# データベースを作成または開く
db = NanaSQLite("mydata.db")

# dictのように使う
db["user"] = {"name": "Nana", "age": 20, "tags": ["admin", "active"]}
print(db["user"])  # {'name': 'Nana', 'age': 20, 'tags': ['admin', 'active']}

# データは自動的に永続化
db.close()

# 後で再度開いても、データはそのまま!
db = NanaSQLite("mydata.db")
print(db["user"]["name"])  # 'Nana'

🔧 高度な使い方

# 一括ロードで繰り返しアクセスを高速化
db = NanaSQLite("mydata.db", bulk_load=True)

# バッチ操作で高速書き込み
db.batch_update({
    "key1": "value1",
    "key2": "value2",
    "key3": {"nested": "data"}
})

# コンテキストマネージャ対応
with NanaSQLite("mydata.db") as db:
    db["temp"] = "value"

📚 ドキュメント


License

MIT License - see LICENSE for details.

Project details


Release history Release notifications | RSS feed

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

nanasqlite-1.0.3rc2.tar.gz (12.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

nanasqlite-1.0.3rc2-py3-none-any.whl (8.2 kB view details)

Uploaded Python 3

File details

Details for the file nanasqlite-1.0.3rc2.tar.gz.

File metadata

  • Download URL: nanasqlite-1.0.3rc2.tar.gz
  • Upload date:
  • Size: 12.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for nanasqlite-1.0.3rc2.tar.gz
Algorithm Hash digest
SHA256 97ceddd98da7d3c86be09443e7f61890138f5be95fd5b531c784d4d89561faf3
MD5 a5126e8d9e7c3f258da45c585a2ea9fe
BLAKE2b-256 76f82f7a3b703e640eb9970b8f30f0843b63088ec372c4c87b09f9a7a3c8a215

See more details on using hashes here.

File details

Details for the file nanasqlite-1.0.3rc2-py3-none-any.whl.

File metadata

  • Download URL: nanasqlite-1.0.3rc2-py3-none-any.whl
  • Upload date:
  • Size: 8.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for nanasqlite-1.0.3rc2-py3-none-any.whl
Algorithm Hash digest
SHA256 f7eeb723db78b1b1dc0e36310c018f9d94434c5567530483ef16b9d06e417156
MD5 804a30569b1009b22003e21ec3c49a7d
BLAKE2b-256 999b26aedd154d7bfd4f33995b6fedf6afd2347e3581230eca0243d75e1b72ce

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page