Skip site navigation (1) Skip section navigation (2)

[ANN] pg.el v0.8 --- socket level Emacs Lisp interface

From: Eric Marsden <emarsden(at)mail(dot)dotcom(dot)fr>
To: pgsql-interfaces(at)postgresql(dot)org
Subject: [ANN] pg.el v0.8 --- socket level Emacs Lisp interface
Date: 2001-05-02 20:37:48
Message-ID: wzioftbwkpv.fsf@mail.dotcom.fr (view raw or flat)
Thread:
Lists: 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, 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/>

pgsql-interfaces by date

Next:From: Lamar OwenDate: 2001-05-02 21:12:24
Subject: Re: Cannot build PL/Perl ...
Previous:From: Adam WalczykiewiczDate: 2001-05-02 19:57:57
Subject: Cannot build PL/Perl ...

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group