Tins · Storage & databases
postgres
A PostgreSQL client over libpq: parameterized statements, typed text-format results, transactions with savepoints and COPY, every error carrying its SQLSTATE — and, in a module of its own, a connection pool for a threaded service. A fork of dvirarad/mojo-postgres, rewritten for the 1.x toolchain.
Install
plain pixi:
pixi init app -c https://conda.modular.com/max -c conda-forge && cd app
sed -i.bak 's/^\[workspace\]/[workspace]\npreview = ["pixi-build"]/' pixi.toml
pixi add "mojo-compiler==1.2.0"
# Without mojoshelf: the tin as a git dependency at its published commit.
# Transitive dependencies may be wrong: pixi takes the tin's own git deps as
# pinned in its pixi.toml, which may not match what other tins pin, and then
# fails with "duplicate records". mojoshelf picks revisions that agree.
pixi add postgres-mojo --git https://github.com/magmalake/postgres.mojo --rev 324b2bb61e2e80327654abecf70fd4b2defbc50d No mojoshelf needed. If pixi reports duplicate records, the mojoshelf tab picks revisions that agree.
Version
0.3.3 on mojoshelf
What it does
Works today
- Every §5 type, with NULL distinct from empty and numeric kept as text
- PQexecParams and prepared statements — no values escaped into SQL
- COPY in and out at 5 M rows/s; handles co-own the connection
- A bounded ConnectionPool behind with pool.lease(): acquire timeouts, is_alive-checked checkout, lifetime and idle recycling, ROLLBACK on return
- A connection whose statement or transaction outlives its lease is closed, never handed to a second thread
- Tested against a throwaway cluster on every CI leg — no Docker
Correctness
Checked against psycopg 3 and psql — cell-exact, both directions
Also in Storage & databases
- objectstore local · HTTP · S3 · GCS · Azure · concurrent reads
- sqlite embedded SQL · the catalog store
- Every tin