Skip to main content
Pre-release

This release is a pre-release and may not be stable for production use.

korbase

An async ORM for Postgres and SQLite, built the Korvex way. It is pure Python. Models are msgspec Structs, dataclasses or TypedDicts. The driver is asyncpg. It has SQL migrations, written for you and applied after review.

Alpha: the API may change before 1.0. Python 3.10 and later.

Install

pip install --pre "korbase[asyncpg]"

SQLite needs no extra. Documentation: https://3d3n-pyc.github.io/korbase/

Example

This runs on a scratch database. The first statement drops the tables users and posts.

from __future__ import annotations
import asyncio
from typing import Annotated, Optional

import msgspec
from korbase import FK, PK, Database, Rel, cols, insert, select, table

DSN = "postgresql://user:password@localhost:5432/scratch"


@table("users")
class User(msgspec.Struct):
    id: Annotated[int, PK()]
    name: str


@table("posts")
class Post(msgspec.Struct):
    id: Annotated[int, PK()]
    author_id: Annotated[int, FK("users.id")]
    title: str
    author: Annotated[Optional[User], Rel("author_id")] = None


async def main() -> None:
    async with await Database.connect(DSN) as db:
        await db.execute(
            """
            DROP TABLE IF EXISTS posts; DROP TABLE IF EXISTS users;
            CREATE TABLE users (id bigint GENERATED BY DEFAULT AS IDENTITY PRIMARY KEY, name text NOT NULL);
            CREATE TABLE posts (id bigint GENERATED BY DEFAULT AS IDENTITY PRIMARY KEY,
                                author_id bigint NOT NULL REFERENCES users(id), title text NOT NULL);
            """
        )
        [ada] = await db.run(insert(User).values(name="Ada"))  # insert returns the new row
        await db.run(insert(Post).values(author_id=ada.id, title="Hello"))

        users = await db.run(select(User).where(name="Ada"))
        print(users)  # [User(id=1, name='Ada')]

        posts = await db.run(select(Post).load(cols(Post).author))
        print([(x.title, x.author.name if x.author else None) for x in posts])


asyncio.run(main())

Docs

The guide is in docs/ in the repository. Start with docs/tutorial.md: it builds a small blog database with migrations, from zero. The docs site is at https://3d3n-pyc.github.io/korbase/, with llms.txt for AI assistants.

Status

Working today: models, queries, transactions, relations loaded with .load(), the Korvex integration (pip install --pre "korbase[korvex]") and SQL migrations with python -m korbase.migrate. SQLite works through the standard library, with a sqlite:///app.db DSN: see docs/sqlite.md.

Not yet: the korpg driver (its extra is empty). .load() raises KorbaseError on tables with a composite primary key.

Tests

eval "$(bash tests/pg/start.sh | grep '^export')"   # Postgres in Docker, port 55433
uv run pytest

Contributor rules are in AGENTS.md. Changes are listed in CHANGELOG.md.

Metadata

Release files for korbase 0.1.0a5

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

Source distribution (sdist)

Source distribution for korbase 0.1.0a5
File Size Uploaded Provenance Actions
korbase-0.1.0a5.tar.gz 239.3 kB With provenance Details for korbase-0.1.0a5.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for korbase 0.1.0a5
File Interpreter ABI Platform Actions
korbase-0.1.0a5-py3-none-any.whl Python 3 none any Details for korbase-0.1.0a5-py3-none-any.whl

Total release size: 309.5 kB

Release files / korbase-0.1.0a5.tar.gz

Download URL korbase-0.1.0a5.tar.gz
Size 239.3 kB
Tags Source
SHA-256 checksum
How to use checksums
61fbdddcf1f4305ee185eb4cdf06be25bc02a4b3de3a6bb85efab9e29882540c
BLAKE2b-256 checksum
How to use checksums
8b4e62e234ba277eff4e2fdbbcdf6ce0f92c74167c0f180e9078ae2de24f9b2e
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 Nov 25, 2026.

Transparency log

Release files / korbase-0.1.0a5-py3-none-any.whl

Download URL korbase-0.1.0a5-py3-none-any.whl
Size 70.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
8244c5a2de85b1fd833f0938cac6ca90f7971604e073ed7d7d85a4e60a9a1bbd
BLAKE2b-256 checksum
How to use checksums
7b16d0a764eea7015f0dca59ad81bc57ce571c02e10c602f07bdf4777ae346d9
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 Nov 25, 2026.

Transparency log

Security for korbase 0.1.0a5

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

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for korbase-0.1.0a5.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 Nov 25, 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.

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