Skip to main content

PyColDB

An educational column-family store (wide-column database) built from scratch in Python. Part of the PyLearn platform for kids aged 12+.

What is a Column-Family Store?

A column-family store is like a spreadsheet where every row can have different columns. Instead of forcing every record to have the same fields, each row picks and chooses what data it stores. Real-world examples include Apache Cassandra and HBase.

Features

  • Columns -- Name-value pairs with timestamps
  • Rows -- Flexible records where each row has its own set of columns
  • Column Families -- Named groups of rows (like gradebooks)
  • Keyspaces -- Top-level containers for column families (like a school)
  • CRUD -- Insert, read, update, and delete columns within rows
  • Range Queries -- Get rows by key range (e.g., keys from "A" to "M")
  • Column Filtering -- Get only specific columns from a row
  • TTL -- Columns can expire after a time-to-live
  • Tombstones -- Soft deletion with markers (like Cassandra)
  • Persistence -- Save and load to JSON files
  • Compaction -- Remove expired and deleted entries to reclaim space

Quick Start

from pycoldb import Keyspace, Column

# Create a keyspace (like a school)
school = Keyspace(name="school")

# Create a column family (like a gradebook)
school.create_column_family("grades")

# Add grades -- each student can have different columns!
school.put("grades", "alice", Column(name="math", value="A+"))
school.put("grades", "alice", Column(name="science", value="A"))
school.put("grades", "bob", Column(name="math", value="B"))
school.put("grades", "bob", Column(name="music", value="A"))

# Read a grade
grade = school.get_column("grades", "alice", "math")
print(f"Alice's math grade: {grade.value}")  # A+

# Range query -- get students from "alice" to "bob"
from pycoldb import range_query
cf = school.get_column_family("grades")
rows = range_query(cf, start_key="alice", end_key="bob")
for row in rows:
    print(f"{row.key}: {row.column_names()}")

# Save to disk
from pycoldb import save_keyspace, load_keyspace
save_keyspace(school, "school.json")
restored = load_keyspace("school.json")

Installation

# From source
git clone https://github.com/robcox2910/pycoldb.git
cd pycoldb
uv sync --all-extras

Development

uv run ruff check src/ tests/      # Lint
uv run ruff format src/ tests/      # Format
uv run pyright src tests            # Type check
uv run pytest                       # Test (90%+ coverage)

Releasing

Other projects in the series (PyStack) use a pinned release of this one, not whatever is on main. To publish a change for them:

  1. Merge the change to main.
  2. Tag it: git tag -a vX.Y.Z -m vX.Y.Z && git push origin vX.Y.Z. A change to the public API bumps the minor version (v0.1.0 → v0.2.0); anything else bumps the patch (v0.1.0 → v0.1.1).
  3. In each project that uses it, edit the tag in [tool.uv.sources], run uv lock --upgrade-package <name>, and open a pull request so CI checks the pair together.

This project is one of a series that builds real systems "from scratch in Python" to teach how they work. See the series home for the full story.

Project What it teaches Repository Docs
PyOS Operating systems py-os Docs
Pebble Compilers and programming languages pebble-lang Docs
PyDB Relational databases pydb Docs
PyKV Key-value stores pykv Docs
PyDocDB Document databases pydoc-db Docs
PyGraphDB Graph databases pygraphdb Docs
PyTSDB Time-series databases pytsdb Docs
PyVecDB Vector databases pyvecdb Docs
PyColDB Column-family databases pycoldb Docs
PyCrypt Cryptography pycrypt Docs
PyNet Computer networking pynet Docs
PyWeb HTTP web servers pyweb Docs
PyGit Version control pygit Docs
PySearch Search engines pysearch Docs
PyMQ Message queues pymq Docs
PyLLM Language models (the brain) pyllm Docs
PyScheduler Job scheduling pyscheduler Docs
PyStack Full-stack integration pystack Docs

Documentation

Full docs (with kid-friendly explanations of every idea): https://robcox2910.github.io/pycoldb/

License

MIT

Metadata

Release files for fromscratch-pycoldb 0.4.0

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

Source distribution (sdist)

Source distribution for fromscratch-pycoldb 0.4.0
File Size Uploaded Provenance
fromscratch_pycoldb-0.4.0.tar.gz 95.2 kB With provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for fromscratch-pycoldb 0.4.0
File Interpreter ABI Platform
fromscratch_pycoldb-0.4.0-py3-none-any.whl Python 3 none any Details

Total release size: 121.7 kB

Release files / fromscratch_pycoldb-0.4.0.tar.gz

Download URL fromscratch_pycoldb-0.4.0.tar.gz
Size 95.2 kB
Tags Source
SHA-256 checksum
How to use checksums
e2d36b6388e3449d22f0fb72d297d660ee34c0d96362edf19819caa79d8c840d
BLAKE2b-256 checksum
How to use checksums
0336cf098b7c6ddf17f23da15836e65544f59e1c0098f7c8da2b45d1b82a9416
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 26, 2026.

Transparency log

Release files / fromscratch_pycoldb-0.4.0-py3-none-any.whl

Download URL fromscratch_pycoldb-0.4.0-py3-none-any.whl
Size 26.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
5238d244292af320f93f05f0f0f7ebc4d37610b37b2c2f891cdbfe47021c317f
BLAKE2b-256 checksum
How to use checksums
892fd1b8ab57318bbef2345e96ae94327ee5f9694593b529c4255934bca572b2
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 26, 2026.

Transparency log

Security for fromscratch-pycoldb 0.4.0

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.

Full provenance

All 2 files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for fromscratch_pycoldb-0.4.0.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 26, 2026.

Transparency log

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.4.0 This release

2 release files Full 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