Lack Middleware Postmodern

Postmodern, written by Marijn Haverbeke, is a robust and mature interface to PostgreSQL. Here’s how it’s described on its homepage:

The biggest differences between this library and clsql or cl-dbi are that Postmodern has no intention of being portable across different SQL implementations (it embraces non-standard PostgreSQL features), and approaches extensions like lispy SQL and database access objects in a quite different way. This library was written because the CLSQL approach did not really work for me. Your mileage may vary.

So for any other 🐘 admirers out there, I’m pleased to announce a new Lack middleware, lack-middleware-postmodern, that provides pooled Postmodern connections for Clack applications.

Sample:

(lack:builder
 (:postmodern :pools `((:pool-id :mydb
                        :database "mydb"
                        :username "myuser"
                        :password nil
                        :host "localhost"
                        :use-binary t
                        :application-name "myapp"
                        :query-log ,(when (developmentp)
                                      *standard-output*)
                        :max-open-count 12
                        :max-idle-count 3
                        :timeout 5000
                        :idle-timeout 40000)
                       (:pool-id :otherdb
                        :database "otherdb"
                        :username "foo"
                        :password "abcxyz"
                        :host "localhost"
                        :use-binary t)))
 *app*)

From your application, you can checkout a connection from the pool by calling macro WITH-POSTMODERN.

(with-postmodern (:mydb)
  (assert (= 1 (pomo:query "select 1" :single))))

See the lack-middleware-postmodern README.md for a full list of pool options.

As usual, should you encounter a problem with the library, you can open an Issue on GitHub.

Postmodern documentation: https://marijnhaverbeke.nl/postmodern/

See also: