Pg

Pg is a socket-level interface to the PostgreSQL? object-relational Database. The Library implements the client part of the frontend/backend protocol, so does not require interfacing with the libpq library. SQL types are converted to the equivalent Common Lisp types where possible. Supports large objects (BLOBs).

The only non portable code is the use of SOCKET-CONNECT. Versions are provided for CMU Common Lisp (CMUCL), SBCL, OpenMCL, CLISP, LispWorks and Allegro Common Lisp (ACL). Corman CL doesn't support binary I/O on socket streams, so it doesn't work there.

Pg is available under the GNU LGPL licence from www.chez.com/emarsden/downloads. There are also Emacs Lisp and scsh versions of the library.

Download ASDF package from http://common-lisp.net/cgi-bin/viewcvs.cgi/root.tar.gz?root=pg&view=tar

This is a snapshot of the CVS repository at common-lisp.net/project/pg and it is not GPG signed.

Here is the last released version, but it's quite old:

http://www.chez.com/emarsden/downloads/pg-dot-lisp-0.19.tar.gz

Sample code:

(with-pg-connection (conn "testdb" "login" :host "dbhost" :password "secret")
   (with-pg-transaction conn
      (when (member "test_date" (pg-tables conn) :test #'string=)
         (pg-exec conn "DROP TABLE test_date"))
      (pg-exec conn "CREATE TABLE test_date(a timestamp, b abstime, c time, d date)")
      (pg-exec conn "INSERT INTO test_date VALUES "
                    "(current_timestamp, 'now', 'now', 'now')")))


Postmodern is a newer and much-much cleaner library. Its cl-postgres asdf system implements the same functionality as Pg -- Attila Lendvai
Stargreen Box Office uses Pg for its database glue layer; it's respectably fast, simple enough to see what it's doing, and impervious to PostgreSQL shared library versioning issues (because it doesn't use them). I'm very happy with it -- Daniel Barlow
You must set unix_socket_directory in your postgresql.conf to /var/run/postgresql
pg doesn't use the default path for the unix domain socket. See Socket Path.

This page is linked from: Categorized Libraries   Changes In Winter 2000-2001   cirCLe   cirCLe Task List  

CLiki pages can be edited by anyone at any time. Imagine a fearsomely comprehensive disclaimer of liability. Now fear, comprehensively