[ANN] pg.el v0.8 --- socket level Emacs Lisp interface - Mailing list pgsql-interfaces

From Eric Marsden
Subject [ANN] pg.el v0.8 --- socket level Emacs Lisp interface
Date
Msg-id wzioftbwkpv.fsf@mail.dotcom.fr
Whole thread Raw
List pgsql-interfaces
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,
aSELECT  statement for setting up the cursor, and a callback function which  will be called on successive tuples
extractedfrom the cursor.
 
  Together with ibuffer this can be used to create a simple but  useful emacs SQL browsing interface with one buffer
pertuple. 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
froma 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/>


pgsql-interfaces by date:

Previous
From: Adam Walczykiewicz
Date:
Subject: Cannot build PL/Perl ...
Next
From: Lamar Owen
Date:
Subject: Re: Cannot build PL/Perl ...