commit d62ba1174046188903bebea58972a6116a589c11
parent c81f6e919f19a642f85a0ba98cd67daa5b8da7c4
Author: Tomas Hlavaty <tom@logand.com>
Date: Tue, 12 Mar 2013 22:52:02 +0100
added mysql support to common lisp plus some sqlite and testing code
Diffstat:
2 files changed, 31 insertions(+), 1 deletion(-)
diff --git a/README b/README
@@ -26,6 +26,7 @@ on symbolic expressions.
* TODO return errors similar to results
* TODO implement query parameters
* TODO port to other common lisps
+* TODO remove mysql password, use ~/.my.cnf instead like ~/.pgpass
* TODO documentation
* TODO extend Emacs-Lisp code to provide something like slime for sql
* TODO change licence of the Java code to MIT or some common Java licence
diff --git a/dbquery.lisp b/dbquery.lisp
@@ -49,6 +49,17 @@
"select 123, 1, 0, null, 12.34, 'hello'"))
(read s)))
+#+nil
+(time
+ (with-program-output (s (list "./dbquery-mysql"
+ "localhost"
+ "tomas"
+ "Ri3OoL3h"
+ "pokus"
+ "select 123, 1, 0, null, 12.34, 'hello'"
+ ))
+ (read s)))
+
(defun make-concurrent-queue ()
(let ((x (cons nil nil))
(l (ccl:make-lock 'concurrent-queue-lock))
@@ -120,16 +131,34 @@
(prog1 (read stream nil nil)
(assert (char= #\newline (read-char stream))))))
+(defun make-sqlite-server (command db)
+ (make-program-server command (list db) 'dbquery-writer 'dbquery-reader))
+
(defun make-pg-server (command connection-info)
(make-program-server command (list connection-info) 'dbquery-writer 'dbquery-reader))
+(defun make-mysql-server (command host user password db)
+ (make-program-server command (list host user password db) 'dbquery-writer 'dbquery-reader))
+
;; (setq c (make-pg-server "cat" "-"))
;; (funcall c "123")
;; (funcall c nil)
;; (funcall c)
+;; (setq c (make-sqlite-server "./dbquery-sqlite" "sqlite.db"))
+;; (time (funcall c "select 1, 2+3"))
+;; (time (funcall c "select 4, 'hello'"))
+;; (funcall c nil)
+;; (funcall c)
+
;; (setq c (make-pg-server "./dbquery-pg" "dbname='pokus' user='tomas'"))
-;; (funcall c "select 1, 2+3")
+;; (time (funcall c "select 1, 2+3"))
+;; (time (funcall c "select 4, 'hello'"))
+;; (funcall c nil)
+;; (funcall c)
+
+;; (setq c (make-mysql-server "./dbquery-mysql" "localhost" "tomas" "Ri3OoL3h" "pokus"))
+;; (time (funcall c "select 1, 2+3"))
;; (time (funcall c "select 4, 'hello'"))
;; (funcall c nil)
;; (funcall c)