Liking cljdoc? Tell your friends :D

psql-clj

Clojars Project cljdoc test

PostgreSQL helpers for Clojure: PG*-, PGSERVICE- and .pgpass-aware connection specs, HikariCP pooling that preserves every pgjdbc connection property, next.jdbc type coercion (JSON/JSONB, ranges, arrays, inet/cidr, geometry, interval, money, enums - read and write), and thin COPY and LISTEN/NOTIFY helpers. PostGIS geometry lives in the psql-clj-gis companion.

Stack

Clojure deps.edn tools.build PostgreSQL PostGIS next.jdbc HikariCP

Installation

The library is split into three artifacts so you only pull what you use. Core has no PostGIS or AWS dependencies.

ArtifactFor
net.clojars.savya/psql-cljconnection specs (PG*/PGSERVICE/.pgpass), pooling, json/jsonb, ranges, arrays, inet/cidr, geometry, interval, money, enums, COPY, LISTEN/NOTIFY
net.clojars.savya/psql-clj-gisPostGIS geometry + geography (pulls postgis-jdbc)
net.clojars.savya/psql-clj-awsRDS/Aurora IAM authentication (pulls the AWS SDK)

deps.edn:

net.clojars.savya/psql-clj     {:mvn/version "2.1.1"}
net.clojars.savya/psql-clj-gis {:mvn/version "2.0.2"}  ;; optional, for PostGIS
net.clojars.savya/psql-clj-aws {:mvn/version "2.0.2"}  ;; optional, for RDS IAM auth

Leiningen:

[net.clojars.savya/psql-clj "2.1.1"]
[net.clojars.savya/psql-clj-gis "2.0.2"]   ;; optional, for PostGIS
[net.clojars.savya/psql-clj-aws "2.0.2"]   ;; optional, for RDS IAM auth

Documentation

COPY streaming (psql.copy) and LISTEN/NOTIFY (psql.notify) are documented in their namespace docstrings on cljdoc.

Development

Core is at the repo root; the companions live under modules/gis and modules/aws and depend on core, so install core locally first.

clojure -M:test && clojure -T:build jar               # core (root)
(cd modules/gis && clojure -M:test && clojure -T:build jar)   # PostGIS companion
(cd modules/aws && clojure -M:test && clojure -T:build jar)   # AWS companion
clojure -M:1.10:test                                  # repeat with :1.11 and :1.12
clojure -T:build deploy                               # publish core to Clojars
(cd modules/gis && clojure -T:build deploy)           # publish gis companion
(cd modules/aws && clojure -T:build deploy)           # publish aws companion

The :integration suites (core and gis) read the standard PG* variables. A quick local PostGIS:

docker run -d -e POSTGRES_PASSWORD=postgres -e POSTGRES_DB=psql_clj_test \
  -p 5432:5432 postgis/postgis:16-3.4
export PGHOST=localhost PGUSER=postgres PGPASSWORD=postgres PGDATABASE=psql_clj_test
clojure -M:test --focus-meta :integration       # core
(cd modules/gis && clojure -M:test --focus-meta :integration)  # gis

License

Copyright © 2014, Remod Oy. All rights reserved.

Maintenance fork (2026) by Savyasachi. Original project: https://github.com/remodoy/clj-postgresql.

Distributed under the BSD 2-Clause License. See LICENSE.

Can you improve this documentation? These fine people already did:
Juho Juopperi, Savyasachi, Søren Sjørup, Phil Jackson, Wulf, TKffTK, Prof Gra & Dan
Edit on GitHub

cljdoc builds & hosts documentation for Clojure/Script libraries

Keyboard shortcuts
Ctrl+kJump to recent docs
Move to previous article
Move to next article
Ctrl+/Jump to the search field
× close