HCoop
/
bpt
/
emacs.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Merge from emacs-23; up to 2010-06-15T03:34:12Z!rgm@gnu.org.
[bpt/emacs.git]
/
lisp
/
org
/
ob-sqlite.el
diff --git
a/lisp/org/ob-sqlite.el
b/lisp/org/ob-sqlite.el
index
7d6930a
..
408ca4e
100644
(file)
--- a/
lisp/org/ob-sqlite.el
+++ b/
lisp/org/ob-sqlite.el
@@
-1,11
+1,11
@@
;;; ob-sqlite.el --- org-babel functions for sqlite database interaction
;;; ob-sqlite.el --- org-babel functions for sqlite database interaction
-;; Copyright (C) 2010 Free Software Foundation
+;; Copyright (C) 2010
-2011
Free Software Foundation
;; Author: Eric Schulte
;; Keywords: literate programming, reproducible research
;; Homepage: http://orgmode.org
;; Author: Eric Schulte
;; Keywords: literate programming, reproducible research
;; Homepage: http://orgmode.org
-;; Version: 7.
01
+;; Version: 7.
4
;; This file is part of GNU Emacs.
;; This file is part of GNU Emacs.
@@
-28,6
+28,7
@@
;;; Code:
(require 'ob)
;;; Code:
(require 'ob)
+(require 'ob-eval)
(require 'ob-ref)
(declare-function org-fill-template "org" (template alist))
(require 'ob-ref)
(declare-function org-fill-template "org" (template alist))
@@
-41,9
+42,10
@@
'(db header echo bail csv column html line list separator nullvalue)
"Sqlite specific header args.")
'(db header echo bail csv column html line list separator nullvalue)
"Sqlite specific header args.")
-(defun org-babel-expand-body:sqlite (body params &optional processed-params)
+(defun org-babel-expand-body:sqlite (body params)
+ "Expand BODY according to the values of PARAMS."
(org-babel-sqlite-expand-vars
(org-babel-sqlite-expand-vars
- body (
or (nth 1 processed-params) (org-babel-ref-variables params
))))
+ body (
mapcar #'cdr (org-babel-get-header params :var
))))
(defvar org-babel-sqlite3-command "sqlite3")
(defvar org-babel-sqlite3-command "sqlite3")
@@
-51,7
+53,6
@@
"Execute a block of Sqlite code with Babel.
This function is called by `org-babel-execute-src-block'."
(let ((result-params (split-string (or (cdr (assoc :results params)) "")))
"Execute a block of Sqlite code with Babel.
This function is called by `org-babel-execute-src-block'."
(let ((result-params (split-string (or (cdr (assoc :results params)) "")))
- (vars (org-babel-ref-variables params))
(db (cdr (assoc :db params)))
(separator (cdr (assoc :separator params)))
(nullvalue (cdr (assoc :nullvalue params)))
(db (cdr (assoc :db params)))
(separator (cdr (assoc :separator params)))
(nullvalue (cdr (assoc :nullvalue params)))
@@
-64,16
+65,10
@@
This function is called by `org-babel-execute-src-block'."
(unless db (error "ob-sqlite: can't evaluate without a database."))
(with-temp-buffer
(insert
(unless db (error "ob-sqlite: can't evaluate without a database."))
(with-temp-buffer
(insert
- (
shell-command-to-string
+ (
org-babel-eval
(org-fill-template
(org-fill-template
- "%cmd
-init %body
%header %separator %nullvalue %others %csv %db "
+ "%cmd %header %separator %nullvalue %others %csv %db "
(list
(list
- (cons "body" ((lambda (sql-file)
- (with-temp-file sql-file
- (insert (org-babel-expand-body:sqlite
- body nil (list nil vars))))
- sql-file)
- (make-temp-file "ob-sqlite-sql")))
(cons "cmd" org-babel-sqlite3-command)
(cons "header" (if headers-p "-header" "-noheader"))
(cons "separator"
(cons "cmd" org-babel-sqlite3-command)
(cons "header" (if headers-p "-header" "-noheader"))
(cons "separator"
@@
-90,7
+85,9
@@
This function is called by `org-babel-execute-src-block'."
(member :html others) separator)
""
"-csv"))
(member :html others) separator)
""
"-csv"))
- (cons "db " db)))))
+ (cons "db " db)))
+ ;; body of the code block
+ (org-babel-expand-body:sqlite body params)))
(if (or (member "scalar" result-params)
(member "html" result-params)
(member "code" result-params)
(if (or (member "scalar" result-params)
(member "html" result-params)
(member "code" result-params)
@@
-117,8
+114,8
@@
This function is called by `org-babel-execute-src-block'."
el
(format "%S" el)))))))
data-file)
el
(format "%S" el)))))))
data-file)
- (
make-temp-file "ob-sqlite-data
"))
- (
format "%S" val
)))
+ (
org-babel-temp-file "sqlite-data-
"))
+ (
if (stringp val) val (format "%S" val)
)))
(cdr pair))
body)))
vars)
(cdr pair))
body)))
vars)
@@
-147,6
+144,5
@@
Prepare SESSION according to the header arguments specified in PARAMS."
(provide 'ob-sqlite)
(provide 'ob-sqlite)
-;; arch-tag: 5c03d7f2-0f72-48b8-bbd1-35aafea248ac
;;; ob-sqlite.el ends here
;;; ob-sqlite.el ends here