From mboxrd@z Thu Jan 1 00:00:00 1970 From: Viktor Rosenfeld Subject: [babel] [PATCH] Add support for MonetDB for SQL blocks Date: Thu, 23 Feb 2012 14:21:13 +0100 Message-ID: <20120223132113.GB2695@kenny.local> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="gKMricLos+KVdGMg" Return-path: Received: from eggs.gnu.org ([140.186.70.92]:51662) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1S0Ybt-0000vV-FP for emacs-orgmode@gnu.org; Thu, 23 Feb 2012 08:21:31 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1S0Ybn-0007yR-A1 for emacs-orgmode@gnu.org; Thu, 23 Feb 2012 08:21:25 -0500 Received: from mail-bk0-f41.google.com ([209.85.214.41]:61052) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1S0Ybm-0007yH-VN for emacs-orgmode@gnu.org; Thu, 23 Feb 2012 08:21:19 -0500 Received: by bkty12 with SMTP id y12so1226315bkt.0 for ; Thu, 23 Feb 2012 05:21:17 -0800 (PST) Content-Disposition: inline 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 --gKMricLos+KVdGMg Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Hi, the attached patch adds support for evaluating SQL blocks on MonetDB. The MonetDB client normally requires the password to be inputted on the console. To get around this, you have to use a dotfile ~/.monetdb with authentification data. Note that this file is ignored if you specify a user on the cmdline. See http://www.monetdb.org/Documentation/mclient-man-page for details. A usage example follows. Setup MonetDB test database and authentification data #+BEGIN_SRC sh :results output verbatim MONETDB_DIR=$HOME/unix/var/monetdb/demodb monetdbd create $MONETDB_DIR monetdbd start $MONETDB_DIR monetdb create demodb monetdb release demodb cat > ~/.monetdb <file - save response in file, or stdout if no file is given \|cmd - pipe result to process, or stop when no command is given \h - show the readline history \D table- dumps the table, or the complete database if none given. \d[Stvsfn]+ [obj] - list database objects, or describe if obj given \A - enable auto commit \a - disable auto commit \e - echo the query in sql formatting mode \f - format using a built-in renderer {csv,tab,raw,sql,xml} \w# - set maximal page width (-1=unlimited, 0=terminal width, >0=limit to num) \r# - set maximum rows per page (-1=raw) \L file - save client/server interaction \X - trace mclient code \q - terminate session #+end_example Have fun! Viktor --gKMricLos+KVdGMg Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename="ob-sql.el.patch" diff --git a/lisp/ob-sql.el b/lisp/ob-sql.el index 68bd95a..20fbad3 100644 --- a/lisp/ob-sql.el +++ b/lisp/ob-sql.el @@ -70,6 +70,10 @@ This function is called by `org-babel-execute-src-block'." (org-babel-temp-file "sql-out-"))) (header-delim "") (command (case (intern engine) + ('monetdb (format "mclient -f tab %s < %s > %s" + (or cmdline "") + (org-babel-process-file-name in-file) + (org-babel-process-file-name out-file))) ('msosql (format "osql %s -s \"\t\" -i %s -o %s" (or cmdline "") (org-babel-process-file-name in-file) --gKMricLos+KVdGMg--