These libraries are experimental. APIs may change without notice. Generated from source with koruc 0.1.7 on 8/19/2026.
pq
@korulang/pq@0.0.1libpq (PostgreSQL) bindings for Koru, lifted behind phantom-typed connection and result obligations
pq/index.kz · 8 tors
@korulang/postgres - PostgreSQL client for Koru
A semantic redesign of libpq using phantom obligations to make
an entire class of database bugs impossible at compile time.
Phantom lifecycles
Derived from the phantom labels in the declarations below — state! issues an
obligation the compiler will chase, !state discharges it, a bare state holds it without moving it. Nothing here is hand-drawn.
Conn 1 state connected!Result 1 state result!// Connection Lifecycle
~pub tor connect { conninfo: string }
| ok *Conn<connected!>
| err string~pub tor disconnect { conn: *Conn<!connected> }// Query Execution
//
// Fire-and-forget: DDL, INSERT/UPDATE/DELETE where you don't need rows back.
// Error message is connection-owned — valid until the next operation on conn.
~pub tor exec { conn: *Conn<connected>, sql: string }
| ok
| err string// Query returning rows. Result carries a <result!> obligation — must be cleared.
~pub tor query { conn: *Conn<connected>, sql: string }
| rows *Result<result!>
| empty
| err string// Number of rows in a result.
~pub tor result.nrows { result: *Result<result> } -> usize// Get a column value by name. Returns the text representation (libpq's native form).
// Branches: some = value present, null = SQL NULL, no-such-col = column name not found.
~pub tor result.col { result: *Result<result>, row: usize, col: string }
| some string
| is-null
| no-such-col// Discharge the result obligation — must be called when done with a result.
~pub tor result.clear { result: *Result<!result> }~[comptime] pub tor sql { conninfo: string, source: Source }
| ok
| err string