Skip to main content

Pure Python in-memory database with SQL-like queries

Project description

DictDB Logo

CI License Python 3.13+ Code style: Ruff Type checking: MyPy


DictDB is a pure Python in-memory database with SQL-like queries.

Installation

pip install dctdb

The PyPI package is dctdb, but the import is dictdb.

Features

  • SQL-like CRUDinsert, select, update, delete, upsert
  • Query DSLtable.age >= 18, table.name.like("A%"), table.salary.between(50000, 100000)
  • Logical operatorsAnd, Or, Not for readable complex queries
  • AggregationsCount, Sum, Avg, Min, Max with GROUP BY
  • Indexes — Hash (O(1) lookup) and Sorted (range queries)
  • Schemas — Optional type validation
  • CSV import/export — Load from and save to CSV files
  • Persistence — JSON and Pickle formats with async support
  • Automatic backups — Periodic and incremental backup manager
  • Thread-safe — Reader-writer locks per table

Quick Example

from dictdb import DictDB, And, Count, Avg

db = DictDB()
db.create_table("users", primary_key="id")
users = db.get_table("users")

# Insert
users.insert({"name": "Alice", "age": 30, "dept": "IT"})
users.insert({"name": "Bob", "age": 25, "dept": "HR"})

# Query with DSL (Condition wrapper is optional)
users.select(where=users.age >= 25)
users.select(where=users.dept == "IT", order_by="-age", limit=10)

# Combine conditions with And/Or/Not
users.select(where=And(users.dept == "IT", users.age >= 25))

# Aggregations
users.aggregate(count=Count(), avg_age=Avg("age"))
users.aggregate(group_by="dept", count=Count())

# Persistence
db.save("data.json", file_format="json")

CSV Import/Export

# Import CSV into a new table
db.import_csv("users.csv", "users", primary_key="id")

# Export table to CSV
users.export_csv("backup.csv")
users.export_csv("it_dept.csv", where=users.dept == "IT")

Documentation

mhbxyz.github.io/dictdb

License

Apache 2.0

Project details


Download files

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

Source Distribution

dctdb-1.11.0.tar.gz (245.9 kB view details)

Uploaded Source

Built Distribution

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

dctdb-1.11.0-py3-none-any.whl (53.0 kB view details)

Uploaded Python 3

File details

Details for the file dctdb-1.11.0.tar.gz.

File metadata

  • Download URL: dctdb-1.11.0.tar.gz
  • Upload date:
  • Size: 245.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for dctdb-1.11.0.tar.gz
Algorithm Hash digest
SHA256 1b68d2ea3b7faa68a01abe6135565a3032b7bb2a532517a6fb8fe34989a536d0
MD5 ec4e6e4390d7435a66190fa1b06a9763
BLAKE2b-256 67b58a523b64590a86ad810bd37c8456d0e39f8c32d13b65891a26ff29fff64a

See more details on using hashes here.

Provenance

The following attestation bundles were made for dctdb-1.11.0.tar.gz:

Publisher: publish.yml on mhbxyz/dictdb

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file dctdb-1.11.0-py3-none-any.whl.

File metadata

  • Download URL: dctdb-1.11.0-py3-none-any.whl
  • Upload date:
  • Size: 53.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for dctdb-1.11.0-py3-none-any.whl
Algorithm Hash digest
SHA256 28e143955ced8f0e6d184574a98357c55bc873b990365b981582228716b5473c
MD5 e4e43291d7b80a8a5e29970f004cdc27
BLAKE2b-256 a9da7ed6434b08a901225a66902e63167a2264d1ae9f34de50495b22eb7b85d7

See more details on using hashes here.

Provenance

The following attestation bundles were made for dctdb-1.11.0-py3-none-any.whl:

Publisher: publish.yml on mhbxyz/dictdb

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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