2sql-cl-postgres.lisp (982B)
1 ;;; cl-2sql Copyright (c) 2011 Tomas Hlavaty 2 3 (defpackage :2sql-cl-postgres 4 (:use :cl) 5 (:export :make-backend)) 6 7 (in-package :2sql-cl-postgres) 8 9 (defun make-backend (db user password host port use-ssl) 10 (let ((x (cl-postgres:open-database db user password host port use-ssl))) 11 (lambda (msg &rest args) 12 (assert x) 13 (ecase msg 14 (:finish 15 (destructuring-bind () args 16 (cl-postgres:close-database x) 17 (setq x nil))) 18 (:query 19 (destructuring-bind (q) args ;; TODO query args 20 (cl-postgres:exec-query x q 'cl-postgres:list-row-reader))) 21 (:prepare 22 (destructuring-bind (stm q &rest args2) args 23 (declare (ignore args2)) ;; TODO args2 24 (cl-postgres:prepare-query x stm q))) 25 (:execute 26 (destructuring-bind (stm &rest args2) args 27 ;; TODO return ctype . cname too 28 (cl-postgres:exec-prepared x stm args2 'cl-postgres:list-row-reader)))))))