;ELC ;;; Compiled ;;; in Emacs version 26.3 ;;; with all optimizations. ;;; This file uses dynamic docstrings, first added in Emacs 19.29. ;;; This file does not contain utf-8 non-ASCII characters, ;;; and so can be loaded in Emacs versions earlier than 23. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; (require 'ob) (defvar org-babel-default-header-args:sql nil) #@32 SQL-specific header arguments. (defconst org-babel-header-args:sql '((engine . :any) (out-file . :any) (dbhost . :any) (dbport . :any) (dbuser . :any) (dbpassword . :any) (database . :any)) (#$ . 469)) #@66 Expand BODY according to the values of PARAMS. (fn BODY PARAMS) (defalias 'org-babel-expand-body:sql #[514 "\300\301!\"\207" [org-babel-sql-expand-vars org-babel--get-vars] 6 (#$ . 677)]) #@156 Set `sql-product' in Org edit buffer. Set `sql-product' in Org edit buffer according to the corresponding :engine source block header argument. (fn INFO) (defalias 'org-babel-edit-prep:sql #[257 "\300\3018\236A\3021\303!0\202\210\304\207" [:engine 2 (user-error) sql-set-product "Cannot set `sql-product' in Org Src edit buffer"] 4 (#$ . 875)]) #@118 Make MySQL cmd line args for database connection. Pass nil to omit that arg. (fn HOST PORT USER PASSWORD DATABASE) (defalias 'org-babel-sql-dbstring-mysql #[1285 "\300\301\302\205\f\303P\205\304\305 \"\205\306P\205(\307P\2051\310P\257\"!\207" [combine-and-quote-strings delq nil "-h" format "-P%d" "-u" "-p" "-D"] 14 (#$ . 1234)]) #@117 Make PostgreSQL command line args for database connection. Pass nil to omit that arg. (fn HOST PORT USER DATABASE) (defalias 'org-babel-sql-dbstring-postgresql #[1028 "\300\301\302\205\f\303P\205\304\305\"\205\306P\205(\307PF\"!\207" [combine-and-quote-strings delq nil "-h" format "-p%d" "-U" "-d"] 12 (#$ . 1601)]) #@336 Make Oracle command line arguments for database connection. If HOST and PORT are nil then don't pass them. This allows you to use names defined in your "TNSNAMES" file. So you can connect with /@:/ or /@ using its alias. (fn HOST PORT USER PASSWORD DATABASE) (defalias 'org-babel-sql-dbstring-oracle #[1285 "\203!\203!\211\203!\203!\203!\300\301&\207\2034\2034\211\2034\300\302$\207\303\304!\207" [format "%s/%s@%s:%s/%s" "%s/%s@%s" user-error "Missing information to connect to database"] 12 (#$ . 1948)]) #@196 Make sqlcmd command line args for database connection. `sqlcmd' is the preferred command line tool to access Microsoft SQL Server on Windows and Linux platform. (fn HOST USER PASSWORD DATABASE) (defalias 'org-babel-sql-dbstring-mssql #[1028 "\300\301\302\303\205\304\305 \"\205\304\306 \"\205\"\304\307 \"\205,\304\310 \"F\"\311#\207" [mapconcat identity delq nil format "-S \"%s\"" "-U \"%s\"" "-P \"%s\"" "-d \"%s\"" " "] 14 (#$ . 2564)]) #@155 Make sqsh command line args for database connection. "sqsh" is one method to access Sybase or MS SQL via Linux platform (fn HOST USER PASSWORD DATABASE) (defalias 'org-babel-sql-dbstring-sqsh #[1028 "\300\301\302\303\205\304\305 \"\205\304\306 \"\205\"\304\307 \"\205,\304\310 \"F\"\311#\207" [mapconcat identity delq nil format "-S \"%s\"" "-U \"%s\"" "-P \"%s\"" "-D \"%s\"" " "] 14 (#$ . 3031)]) #@123 Make Vertica command line args for database connection. Pass nil to omit that arg. (fn HOST PORT USER PASSWORD DATABASE) (defalias 'org-babel-sql-dbstring-vertica #[1285 "\300\301\302\303\205\304\305\n\"\205\304\306\n\"\205\"\304\307\n\"\205.\304\310\311 !\"\2058\304\312\n\"\257\"\313#\207" [mapconcat identity delq nil format "-h %s" "-p %d" "-U %s" "-w %s" shell-quote-argument "-d %s" " "] 16 (#$ . 3456)]) #@227 Convert FILE to OS standard file name. If in Cygwin environment, uses Cygwin specific function to convert the file name. In a Windows-NT environment, do nothing. Otherwise, use Emacs' standard conversion function. (fn FILE) (defalias 'org-babel-sql-convert-standard-filename #[257 "\301\302!\203 \303\304\302!\"\207\305\230\203\207\303\304\306!\"\207" [system-type fboundp cygwin-convert-file-name-to-windows format "%S" "windows-nt" convert-standard-filename] 5 (#$ . 3898)]) #@336 Return database connection parameter NAME. Given a parameter NAME, if :dbconnection is defined in PARAMS then look for the parameter into the corresponding connection defined in `sql-connection-alist`, otherwise look into PARAMS. Look `sql-connection-alist` (part of SQL mode) for how to define database connections. (fn PARAMS NAME) (defalias 'org-babel-find-db-connection-param #[514 "\301\236\203\301\236A\302\236A\211\303\"A\236A@\207\211\236A\207" [sql-connection-alist :dbconnection ((:dbhost . sql-server) (:dbport . sql-port) (:dbuser . sql-user) (:dbpassword . sql-password) (:database . sql-database)) assoc] 9 (#$ . 4390)]) #@117 Execute a block of Sql code with Babel. This function is called by `org-babel-execute-src-block'. (fn BODY PARAMS) (defalias 'org-babel-execute:sql #[514 "\301\236A\302\236A\303\304\"\303\305\"\303\306\"\303\307\"\303\310\"\311\236A\312 \236A\313\232?\314\315!\316 \236A\2069\314\317!\320C\321!\322\323\"\203Z\324\325 \206M\320\326!\327\326!%\202\217\322\330\"\203u\324\331 \206i\320\326!\326!$\202\217\322\332\"\203\236\324\333 \206\204\320\334   $\335\326 !!\335\326 !!%\202\217\322\336\"\203\320\324\337\340     %\203\274\320\202\275\341\206\303\320\326 !\326 !&\202\217\342\343\"\203\324\344 \203\346\324\345 \"\202\347\320\346\300!\203\361\206\362\347\203\373\320\202\374\350\351$\326\n!\326\n!\206\320&\202\217\322\352\"\203B\324\353 \206(\320\354   $\335\326 !!\335\326 !!%\202\217\322\355\"\203i\324\356\357     %\326!\326!\206e\320%\202\217\322\360\"\203\212\324\361\362     %\326!\326!$\202\217\363\364\"\262\365\366\367!!\370\371\372\373\374!\375\"\376$\216r\211q\210\321!\211\323=\203\265\377\202\334\211\360=\203\301\201@\202\334\211\201A>\203\317\201B\202\334\211\355=\203\333\201C\202\334\320\262\201D\" \201E\230\203\365\201F\202\366\320\261\210)r\211q\210\201G\201H\211\201H\371%\210*\266\201I\320\"\210\f\201J\235?\205\325\201K\235\204y\201L\235\204y\201M\235\204y\201N\235\204y\201O\235\204y\201P\235\204y\201Q\235\204q\201R\235\204q\201S\235\204q\201T\235\203\242\201U\235\204\242\201V\201W!r\211q\210\370\371\372\373\374!\201X\"\376$\216\201Y!\210\201Z *\262\202\325\201V\201W!r\211q\210\370\371\372\373\374!\201[\"\376$\216\321!\201\\>\203\n\203u\201V\201W!r\211q\210\370\371\372\373\374!\201]\"\376$\216\201^!\210eb\210\201_y\210\201`c\210\201a\240\210\201b!\210*\210\202u\201V\201W!r\211q\210\370\371\372\373\374!\201c\"\376$\216\201^!\210eb\210\201d\201e\201H\201f#\203G\201g\201_!\240\210db\210\201hu\210\201i\201j!\203l\201k\201_!\210db\210\201hu\210\202O\201b!\210*\210\201l \201E\230\203\210\201m\202\213\201n\"\210\201o\201p\370\201q\201r\373\374\n!\201s\"\201t\201u%\201v \"\201w\201x\236A\312\236A\"\201w\201y\236A\201z\236A\"#*\262\262\207" [sql-postgres-program :result-params :cmdline org-babel-find-db-connection-param :dbhost :dbport :dbuser :dbpassword :database :engine :colnames "no" org-babel-temp-file "sql-in-" :out-file "sql-out-" "" intern eql dbi format "dbish --batch %s < %s | sed '%s' > %s" org-babel-process-file-name "/^+/d;s/^|//;s/(NULL)/ /g;$d" monetdb "mclient -f tab %s < %s > %s" mssql "sqlcmd %s -s \" \" %s -i %s -o %s" org-babel-sql-dbstring-mssql org-babel-sql-convert-standard-filename mysql "mysql %s %s %s < %s > %s" org-babel-sql-dbstring-mysql "-N" memql (postgresql postgres) "%s%s --set=\"ON_ERROR_STOP=1\" %s -A -P footer=off -F \" \" %s -f %s -o %s %s" "PGPASSWORD=%s " boundp "psql" "-t" org-babel-sql-dbstring-postgresql sqsh "sqsh %s %s -i %s -o %s -m csv" org-babel-sql-dbstring-sqsh vertica "vsql %s -f %s -o %s %s" org-babel-sql-dbstring-vertica oracle "sqlplus -s %s < %s > %s" org-babel-sql-dbstring-oracle user-error "No support for the %s SQL engine" get-buffer-create generate-new-buffer-name " *temp file*" make-byte-code 0 "\301\300!\205 \302\300!\207" vconcat vector [buffer-name kill-buffer] 2 "/format partbox\n" "SET PAGESIZE 50000\nSET NEWPAGE 0\nSET TAB OFF\nSET SPACE 0\nSET LINESIZE 9999\nSET TRIMOUT ON TRIMSPOOL ON\nSET ECHO OFF\nSET FEEDBACK OFF\nSET VERIFY OFF\nSET HEADING ON\nSET MARKUP HTML OFF SPOOL OFF\nSET COLSEP '|'\n\n" (sqsh mssql) "SET NOCOUNT ON\n\n" "\\a\n" org-babel-expand-body:sql "sqsh" "\ngo" write-region nil org-babel-eval "none" "scalar" "verbatim" "html" "code" "pp" "file" "output" "raw" "org" "drawer" "table" generate-new-buffer " *temp*" [buffer-name kill-buffer] insert-file-contents-literally buffer-string [buffer-name kill-buffer] (dbi mysql postgresql postgres sqsh vertica) [buffer-name kill-buffer] insert-file-contents 1 "-\n" "-" write-file [buffer-name kill-buffer] re-search-forward "^\\(-+\\)[^-]" t match-string-no-properties -1 looking-at "\n" delete-char org-table-import (4) (16) org-babel-reassemble-table mapcar 257 "\211@\300\242\230\203\n\301\207\207" [hline] 3 "\n\n(fn X)" org-table-to-lisp org-babel-pick-name :colname-names :rowname-names :rownames] 25 (#$ . 5042)]) #@60 Expand the variables held in VARS in BODY. (fn BODY VARS) (defalias 'org-babel-sql-expand-vars #[514 "C\300\301\302\303\304\305!\306\"\307\310%\"\210\211\242\207" [mapc make-byte-code 257 "\300\301\302\303@\"A\211<\203C\304\305!\211\306\307\310!!\311\312\313\314\315!\316\"\317$\216r\211q\210\320\321\"c\210)r\211q\210\322\323\211\323\312%\210*\266\211\262\202P\211;\203L\211\202P\302\324\"\262\300\242#\240\207" vconcat vector [replace-regexp-in-string format "$%s" org-babel-temp-file "sql-data-" get-buffer-create generate-new-buffer-name " *temp file*" make-byte-code 0 "\301\300!\205 \302\300!\207" vconcat vector [buffer-name kill-buffer] 2 orgtbl-to-csv (:fmt (lambda (el) (if (stringp el) el (format "%S" el)))) write-region nil "%S"] 14 "\n\n(fn PAIR)"] 10 (#$ . 9564)]) #@78 Raise an error because Sql sessions aren't implemented. (fn SESSION PARAMS) (defalias 'org-babel-prep-session:sql #[514 "\300\301!\207" [error "SQL sessions not yet implemented"] 4 (#$ . 10369)]) (provide 'ob-sql)