v0.1.1

Database schemas
as knowledge graphs.

okc reads a database schema and produces an OKF bundle — a directory of cross-linked markdown documents that turn your schema into a navigable knowledge graph.

# Introspect any SQLite or PostgreSQL database
$ okc introspect sqlite:///path/to/database.db --out ./my-bundle

# Output:
my-bundle/
├── index.md
├── tables/
│ ├── index.md
│ ├── users.md
│ └── orders.md
└── views/
├── index.md
└── active_orders.md
Capabilities

What okc does

A focused tool with strong opinions about determinism, portability, and zero configuration.

Deterministic Output

Same database, same schema — identical bundle every time. No randomness, no drift. Reliable for CI/CD pipelines and version control.

Multi-Backend

Introspect SQLite and PostgreSQL databases through a shared Source interface. Add new backends without changing the bundle layer.

Standards-Based

Generates valid OKF v0.1 documents with type, title, description, resource, tags, and timestamp frontmatter.

Cross-Linked

Foreign key relationships become navigable markdown links across documents. Every REFERENCES constraint is a hyperlink.

Auto-Indexed

index.md files are generated for every directory, listing both subdirectories and typed entries. Navigation is built in.

Zero-Config

Point it at a database URL and get a bundle. No config files, no YAML schemas to write, no DSL to learn.

Getting Started

Install and run in two commands

okc is a Python CLI. Install from PyPI or source, point it at a database, and get an OKF bundle.

Installation

# Install from PyPI
$ pip install okc

# Or install from source
$ git clone https://github.com/Auran0s/okc
$ cd okc
$ pip install -e .

# With dev dependencies
$ pip install -e ".[dev]"

Usage

# Introspect a SQLite database
$ okc introspect sqlite:///path/to/database.db --out ./my-bundle

# Custom output directory
$ okc introspect sqlite:///path/to/database.db --out ./docs/database

# Introspect PostgreSQL
$ okc introspect postgresql://user:password@localhost:5432/mydb --out ./pg-bundle

# JSON output (for CI/CD)
$ okc introspect --json sqlite:///path/to/database.db

CLI Reference

Argument Required Default Description
url Yes Database URL (sqlite:// or postgresql://)
--out No ./okf-bundle Output directory for generated bundle
--quiet No false Suppress stdout (stderr still flows)
--json No false Output structured JSON instead of styled terminal
--version No Print version and exit
Documentation

Backends, format, and architecture

Everything you need to understand how okc works and what it produces.

Supported Backends

SQLite
sqlite — file-based, zero configuration
sqlite:///path/to/file.db
PostgreSQL
postgresql — full schema support, multi-schema bundles
postgresql://user:password@host:5432/db

OKF Bundle Format

Each concept document captures one database object. Documents are cross-linked, indexed, and validated against directory traversal attacks.

# Directory structure (single schema)
my-bundle/
├── index.md
├── tables/
│ ├── index.md
│ ├── users.md
│ ├── orders.md
│ └── products.md
└── views/
├── index.md
└── active_orders.md
# PostgreSQL multi-schema
my-bundle/
└── tables/
├── index.md
├── public/
│ ├── index.md
│ ├── users.md
│ └── orders.md
└── audit/
├── index.md
└── log.md
# YAML frontmatter
---
type: table
title: users
description: Registered user accounts
resource: sqlite:///path/to/database.db
tags: []
timestamp: "2026-06-17T12:00:00Z"
---

Document body sections

Lists every column with name, type, nullable status, default value, and description. Rendered as a markdown table.
Primary keys, UNIQUE constraints, CHECK constraints, and EXCLUSION constraints for tables. Each with name, columns, and definition.
Index name, columns, uniqueness flag, and index method for each table index.
Outgoing foreign keys with markdown cross-links to target tables. The Referenced By section shows incoming FKs with links from source tables.