Browse Source

Add dbi support to sql babel mode

* lisp/ob-sql.el: add dbi engine type and pre/post processing
Rick Frankel 13 years ago
parent
commit
eed31ad936
1 changed files with 10 additions and 1 deletions
  1. 10 1
      lisp/ob-sql.el

+ 10 - 1
lisp/ob-sql.el

@@ -71,6 +71,11 @@ This function is called by `org-babel-execute-src-block'."
                        (org-babel-temp-file "sql-out-")))
 	 (header-delim "")
          (command (case (intern engine)
+                    ('dbi (format "dbish --batch '%s' < %s | sed '%s' > %s"
+				  (or cmdline "")
+				  (org-babel-process-file-name in-file)
+				  "/^+/d;s/^\|//;$d"
+				  (org-babel-process-file-name out-file)))
                     ('monetdb (format "mclient -f tab %s < %s > %s"
                                       (or cmdline "")
                                       (org-babel-process-file-name in-file)
@@ -90,7 +95,11 @@ This function is called by `org-babel-execute-src-block'."
 				    (or cmdline "")))
                     (t (error "no support for the %s sql engine" engine)))))
     (with-temp-file in-file
-      (insert (org-babel-expand-body:sql body params)))
+      (insert
+       (case (intern engine)
+	 ('dbi "/format partbox\n")
+	 (t ""))
+       (org-babel-expand-body:sql body params)))
     (message command)
     (shell-command command)
     (if (or (member "scalar" result-params)