Liking cljdoc? Tell your friends :D

psql-clj

Clojars Project cljdoc test

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.

Stack

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

Installation

The library has three artifacts. 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.3.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.3.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

Documentation

The psql.copy and psql.notify namespace docstrings describe COPY streaming and LISTEN/NOTIFY on cljdoc.

Development

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

License

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 & 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