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 will be at https://3d3n-pyc.github.io/korbase/ once it is public.

Status

Working today: models, queries, transactions, relations loaded with .load(), the Korvex integration (pip install "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.0a2

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

Built distribution (wheel)

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

Total release size: 265.7 kB

Release files / korbase-0.1.0a2.tar.gz

Download URL korbase-0.1.0a2.tar.gz
Size 207.0 kB
Tags Source
SHA-256 checksum
How to use checksums
c23e5af51bb1685e90aac7d6ca09f126bd4fbe797d1ee1eb8b3b3129309f6a78
BLAKE2b-256 checksum
How to use checksums
5a9a6f72a895977dfa5e5cef57387d7127438bf4955d7a2affdbd88c8a682080
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.0a2-py3-none-any.whl

Download URL korbase-0.1.0a2-py3-none-any.whl
Size 58.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
986764044385a769cd41dc395c7ee9017e002ac45b3efeb172a50751fd725136
BLAKE2b-256 checksum
How to use checksums
8a4b83910f0d67929a8cd78177fa9cf3ead5896de16eaf695813f040275f8425
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.0a2

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.0a2.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