pg.ddx.io  pgsql-interfaces@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Eric Marsden <emarsden@mail.dotcom.fr>
To: pgsql-interfaces@postgresql.org
Subject: [ANN] pg.el v0.8 --- socket level Emacs Lisp interface
Date: 02 May 2001 22:37:48 +0200
Message-ID: <wzioftbwkpv.fsf@mail.dotcom.fr> (raw)

pg.el is a socket-level interface to PostgreSQL for emacs (text editor
extraordinaire). The module is capable of type coercions from a range
of SQL types to the equivalent Emacs Lisp type. It has
internationalization support (if PostgreSQL was compiled with
multibyte support, it will convert multibyte data to the appropriate
emacs internal encoding) and supports large objects. Works with both
Emacs and XEmacs flavors.

This is mainly a programmer's API; it doesn't provide any form of
user-oriented interface.  Sample code:

,----
| (with-pg-connection conn ("template1" "user" "secret" "host")
|    (if (member "pgeltest" (pg:databases conn))
|        (pg:exec conn "DROP DATABASE count_test")
|      (pg:exec conn "CREATE TABLE count_test(key int, val int)")
|      (loop for i from 1 to 100
|            for sql = (format "INSERT INTO count_test VALUES(%s, %s)" i (* i i))
|            do (pg:exec conn sql))
|      (setq res (pg:exec conn "SELECT sum(key) FROM count_test"))
|      (assert (= 5050 (first (pg:result res :tuple 0))))
|      (pg:exec conn "DROP TABLE count_test")))
`----


Changes since last release:

 * added support for PostgreSQL 7.1 type ISO dates (accept fractional
   seconds), thanks to Doug McNaught

 * bugfixes to large object functions, thanks to Doug McNaught

 * added function `pg:for-each' for traversing large data sets using
   SQL cursors. Arguments are a database connection, a SELECT
   statement for setting up the cursor, and a callback function which
   will be called on successive tuples extracted from the cursor.

   Together with ibuffer this can be used to create a simple but
   useful emacs SQL browsing interface with one buffer per tuple. Use
   a callback function which does

       (set-buffer (get-buffer-create "mycursor"))
       (insert (fiddle-with tuple))

   then explore and delete the tuple buffers using "/ n mycursor".
   Unfortunately PostgreSQL doesn't let you do updates from a cursor,
   so this is a readonly interface. 

   You can stop the traversal of the cursor from the callback function
   by throwing to a tag named 'pg-finished. 


pg.el (and a similar library for Common Lisp) is available under GNU
GPL from

   <URL:http://www.chez.com/emarsden/downloads/;

One of these days it should be bundled with the GNU Emacs (this is the
reason for the choice of licence). 

-- 
Eric Marsden                          <URL:http://www.laas.fr/~emarsden/;



Message-ID: <wzioftbwkpv.fsf@mail.dotcom.fr>
Permalink:  ../wzioftbwkpv.fsf@mail.dotcom.fr/
Also on:    postgresql.org/message-id/wzioftbwkpv.fsf@mail.dotcom.fr

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-interfaces@postgresql.org
  Cc: emarsden@mail.dotcom.fr
  Subject: Re: [ANN] pg.el v0.8 --- socket level Emacs Lisp interface
  In-Reply-To: <wzioftbwkpv.fsf@mail.dotcom.fr>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox