Pique (pēk) is a Clojure library to read the system environment for PostgreSQL parameters in the same manner as libpq.
NOTE: This is alpha. The little API it has is not stable.
Releases are on Clojars.
Clojure CLI/deps.edn coordinates:
{com.grzm/pique.alpha {:mvn/version "0.1.6"}}[com.grzm/pique.alpha "0.1.6"]Maven dependency information:
<dependency>
<groupId>com.grzm</groupId>
<artifactId>pique.alpha</artifactId>
<version>0.1.6</version>
</dependency>Easily use your PostgreSQL environment variables, service files, and .pgpass
with clojure.java.jdbc:
(require
'[clojure.java.jdbc :as jdbc]
'[com.grzm.pique.jdbc :as env])
;; PGDATABASE, PGUSER set in environment
(env/spec)
;; => {:port 5496, :dbname "pique", :user "grzm", :dbtype "postgresql"}
(jdbc/query (env/spec) "SELECT 'Oh, so pleasant!' AS life_with_pique")
;; => ({:life_with_pique "Oh, so pleasant!!"})clojure.java.jdbc doesn't use all of the parameters that are
utilized by libpq (and renames some of the canonical libpq parameter
names, and aren't exposed by jdbc/spec. You can access all libpq
parameters that have been defined in the environment as well:
(require '[com.grzm.pique.env :as env])
(env/params)
;; => {:database "pique", :port 5496, :user "grzm"}Pique reads the same environment variables and
connection service and
password files used by libpq. This includes common
enviroment variables such as PGDATABASE and PGUSER, and also
PGSERVICEFILE and PGPASSFILE. Connection service files (e.g.,
~/.pg_service.conf) and password files (e.g., ~/.pgpass) are also
read, just like libpq clients such as psql.
Not all libpq connection parameters make sense for JDBC, but those
that do are used to create the connection spec.
© 2017 Michael Glaesemann
Released under the MIT License. See LICENSE for details.