[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[O] (no subject)
From: |
Rick Frankel |
Subject: |
[O] (no subject) |
Date: |
Fri, 11 May 2012 16:56:48 -0400 (EDT) |
>From 113bbbe1ce9540e2af8c613ba655599fc474cedd Mon Sep 17 00:00:00 2001
From: Rick Frankel <address@hidden>
Date: Fri, 11 May 2012 16:54:32 -0400
Subject: [PATCH] Add support for perl dbi to SQL code block
* lisp/ob-sql.el (org-babel-execute:sql): Add dbi as a suppored engine.
Invokes `dbish' with the arguments specified to ":cmdline". Minimum is
usually the "dbi:{dbd}" argument, plus the username and password if
required.
For example:
#+begin_src sql :engine dbi :cmdline dbi:Pg:database=postgres
---
lisp/ob-sql.el | 11 ++++++++++-
1 file changed, 10 insertions(+), 1 deletion(-)
diff --git a/lisp/ob-sql.el b/lisp/ob-sql.el
index e3f6edd..c6d4790 100644
--- a/lisp/ob-sql.el
+++ b/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)
--
1.7.10.1
- [O] (no subject),
Rick Frankel <=