From mboxrd@z Thu Jan 1 00:00:00 1970 From: rick@rickster.com (Rick Frankel) Subject: (no subject) Date: Fri, 11 May 2012 16:56:48 -0400 (EDT) Message-ID: <20120511205649.14CB015ACCA6@BigDog.local> Return-path: Received: from eggs.gnu.org ([208.118.235.92]:58904) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SSxSV-0003Va-Ay for emacs-orgmode@gnu.org; Fri, 11 May 2012 17:33:08 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1SSxST-0000hs-F4 for emacs-orgmode@gnu.org; Fri, 11 May 2012 17:33:06 -0400 Received: from [204.62.15.78] (port=57284 helo=mail.rickster.com) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SSxST-0000cL-BV for emacs-orgmode@gnu.org; Fri, 11 May 2012 17:33:05 -0400 Received: from BigDog.local (pool-173-68-170-125.nycmny.fios.verizon.net [173.68.170.125]) by mail.rickster.com (Postfix) with ESMTPS id 2E9A3222C1 for ; Fri, 11 May 2012 16:57:01 -0400 (EDT) List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Sender: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org To: emacs-orgmode@gnu.org >From 113bbbe1ce9540e2af8c613ba655599fc474cedd Mon Sep 17 00:00:00 2001 From: Rick Frankel 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