PostgreSQL helpers for Clojure: connection specs that use PG*, PGSERVICE, and .pgpass; HikariCP pools that keep pgjdbc properties; and next.jdbc type coercion. It supports JSON/JSONB, ranges, arrays, inet/cidr, geometry, interval, money, and enums. It also provides COPY and LISTEN/NOTIFY helpers. The psql-clj-gis companion provides PostGIS geometry.
The library has three artifacts. Core has no PostGIS or AWS dependencies.
| Artifact | For |
|---|---|
net.clojars.savya/psql-clj | connection specs (PG*/PGSERVICE/.pgpass), pooling, json/jsonb, ranges, arrays, inet/cidr, geometry, interval, money, enums, COPY, LISTEN/NOTIFY |
net.clojars.savya/psql-clj-gis | PostGIS geometry + geography (pulls postgis-jdbc) |
net.clojars.savya/psql-clj-aws | RDS/Aurora IAM authentication (pulls the AWS SDK) |
deps.edn:
net.clojars.savya/psql-clj {:mvn/version "2.4.0"}
net.clojars.savya/psql-clj-gis {:mvn/version "2.1.0"} ;; 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.4.0"]
[net.clojars.savya/psql-clj-gis "2.1.0"] ;; optional, for PostGIS
[net.clojars.savya/psql-clj-aws "2.0.2"] ;; optional, for RDS IAM auth
The psql.copy and psql.notify namespace docstrings describe COPY streaming and LISTEN/NOTIFY on cljdoc.
Core is at the repository root. The companions are in modules/gis and
modules/aws. They 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 core and GIS :integration suites read the standard PG* variables. Start a local PostGIS instance:
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
Copyright © 2014, Remod Oy. All rights reserved.
Maintenance fork from 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 & DanEdit on GitHub
cljdoc builds & hosts documentation for Clojure/Script libraries
| Ctrl+k | Jump to recent docs |
| ← | Move to previous article |
| → | Move to next article |
| Ctrl+/ | Jump to the search field |