This is the mail archive of the guile@cygnus.com mailing list for the guile project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: Talking to PostgreSQL


>>>>> "CD" == Ciaran Dunn <cdunn@newton.com.au> writes:

  CD> Im new to guile(and scheme for that matter) an was wondering if
  CD> it is possible to talk to PostgreSQL DBs in guile? If not is
  CD> anyone working on this?

I have written a socket-level interface to PostgreSQL for scsh (not a
wrapper around libpq). The module is capable of type coercions from a
range of SQL types to the equivalent Scheme type, but does not support
crypt authentication nor BLOBs.I don't know where the scsh emulation
package is, but it shouldn't be difficult to port the code to the
native Guile API if necessary. The code is available under LGPL from

   <URL:http://www.chez.com/emarsden/downloads/pgscsh-0.1.tar.gz>


Here is a taste of the API:
   
 (define (demo)
    (let* ((conn (pg:connect "template1" "postgres" "postgres"))
           (res (pg:exec conn "SELECT * from scshdemo WHERE a = 42")))
      (format #t "status is ~s~%"   (pg:result res 'status))
      (format #t "metadata is ~s~%" (pg:result res 'attributes))
      (format #t "data is ~s~%"     (pg:result res 'tuples))
      (pg:disconnect conn)))

-- 
Eric Marsden
emarsden @ mail.dotcom.fr
It's elephants all the way down