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: joins in the query builder, and 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.0a3

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.0a3
File Size Uploaded Provenance Actions
korbase-0.1.0a3.tar.gz 207.8 kB With provenance Details for korbase-0.1.0a3.tar.gz

Built distribution (wheel)

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

Total release size: 266.5 kB

Release files / korbase-0.1.0a3.tar.gz

Download URL korbase-0.1.0a3.tar.gz
Size 207.8 kB
Tags Source
SHA-256 checksum
How to use checksums
e2c05cf1de0ee5c4f5ba05b235d60135123da1c8090a2b496309f7ab625822c6
BLAKE2b-256 checksum
How to use checksums
2e170aa65b021408455109f2b387353d91e3759b4f295ca3fc88a78d9965d140
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 20, 2026.

Transparency log

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

Download URL korbase-0.1.0a3-py3-none-any.whl
Size 58.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
4e0aa922b04a997df0c12eafa819fd5f2242ca103bca78426825c4f5cd24e797
BLAKE2b-256 checksum
How to use checksums
57b9d58eb2e73b0e19d0d776b9588350c25d386cf1c0c6e3faa59d3b0449358c
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 20, 2026.

Transparency log

Security for korbase 0.1.0a3

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.0a3.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 20, 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