Received: from laas.laas.fr (laas.laas.fr [140.93.0.15]) by postgresql.org (8.11.3/8.11.1) with ESMTP id f42KXNA72105 for ; Wed, 2 May 2001 16:33:24 -0400 (EDT) (envelope-from emarsden@laas.fr) Received: from elgar.laas.fr (elgar [140.93.21.57]) by laas.laas.fr (8.11.3/8.11.3) with ESMTP id f42KXMD14754 for ; Wed, 2 May 2001 22:33:22 +0200 (MET DST) Received: (from emarsden@localhost) by elgar.laas.fr (8.9.3/8.9.3) id WAA21540; Wed, 2 May 2001 22:37:49 +0200 (MET DST) To: pgsql-interfaces@postgresql.org Subject: [ANN] pg.el v0.8 --- socket level Emacs Lisp interface From: Eric Marsden Organization: LAAS-CNRS http://www.laas.fr/ X-Eric-Conspiracy: there is no conspiracy X-Attribution: ecm X-URL: http://www.chez.com/emarsden/ Date: 02 May 2001 22:37:48 +0200 Message-ID: Lines: 62 User-Agent: Gnus/5.0808 (Gnus v5.8.8) Emacs/20.6 MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Archive-Number: 200105/6 X-Sequence-Number: 1530 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 One of these days it should be bundled with the GNU Emacs (this is the reason for the choice of licence). -- Eric Marsden