emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* [PATCH] ob-sql: Add support for Athena
@ 2023-01-16 10:48 Daniel Kraus
  2023-01-16 11:13 ` Ihor Radchenko
  0 siblings, 1 reply; 33+ messages in thread
From: Daniel Kraus @ 2023-01-16 10:48 UTC (permalink / raw)
  To: emacs-orgmode

[-- Attachment #1: Type: text/plain, Size: 282 bytes --]

Hi,

I'm using this patch since a few month that adds support
for AWS Athena.
The only thing that's maybe against adding it is that
`athenacli` (https://github.com/dbcli/athenacli) is not an
official AWS tool but just a Python script.

What's the opinion on this?

Cheers,
  Daniel

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-lisp-ob-sql.el-Add-support-for-Athena.patch --]
[-- Type: text/x-patch, Size: 2150 bytes --]

From ddace051205d20b24c047962ca9d1335bdd90284 Mon Sep 17 00:00:00 2001
From: Daniel Kraus <daniel@kraus.my>
Date: Mon, 16 Jan 2023 11:35:02 +0100
Subject: [PATCH] lisp/ob-sql.el: Add support for Athena

* lisp/ob-sql.el (org-babel-execute:sql): Add support for Athena
---
 lisp/ob-sql.el | 18 ++++++++++++------
 1 file changed, 12 insertions(+), 6 deletions(-)

diff --git a/lisp/ob-sql.el b/lisp/ob-sql.el
index 39a4573a5..640ecb2c0 100644
--- a/lisp/ob-sql.el
+++ b/lisp/ob-sql.el
@@ -53,14 +53,15 @@
 ;; - rowname-names
 ;;
 ;; Engines supported:
-;; - mysql
+;; - athena
 ;; - dbi
 ;; - mssql
-;; - sqsh
-;; - postgresql (postgres)
+;; - mysql
 ;; - oracle
-;; - vertica
+;; - postgresql (postgres)
 ;; - saphana
+;; - sqsh
+;; - vertica
 ;;
 ;; TODO:
 ;;
@@ -254,6 +255,11 @@ This function is called by `org-babel-execute-src-block'."
                        (org-babel-temp-file "sql-out-")))
 	 (header-delim "")
          (command (cl-case (intern engine)
+                    (athena (format "athenacli %s -e %s %s > %s"
+			            (or cmdline "")
+			            (org-babel-process-file-name in-file)
+                                    database
+			            (org-babel-process-file-name out-file)))
                     (dbi (format "dbish --batch %s < %s | sed '%s' > %s"
 				 (or cmdline "")
 				 (org-babel-process-file-name in-file)
@@ -352,7 +358,7 @@ SET COLSEP '|'
 	(progn (insert-file-contents-literally out-file) (buffer-string)))
       (with-temp-buffer
 	(cond
-	 ((memq (intern engine) '(dbi mysql postgresql postgres saphana sqsh vertica))
+	 ((memq (intern engine) '(athena dbi mysql postgresql postgres saphana sqsh vertica))
 	  ;; Add header row delimiter after column-names header in first line
 	  (cond
 	   (colnames-p
@@ -377,7 +383,7 @@ SET COLSEP '|'
 	      (goto-char (point-max))
 	      (forward-char -1))
 	    (write-file out-file))))
-	(org-table-import out-file (if (string= engine "sqsh") '(4) '(16)))
+	(org-table-import out-file (if (memq (intern engine) '(athena sqsh)) '(4) '(16)))
 	(org-babel-reassemble-table
 	 (mapcar (lambda (x)
 		   (if (string= (car x) header-delim)
-- 
2.39.0


^ permalink raw reply related	[flat|nested] 33+ messages in thread

end of thread, other threads:[~2023-02-26  3:00 UTC | newest]

Thread overview: 33+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-01-16 10:48 [PATCH] ob-sql: Add support for Athena Daniel Kraus
2023-01-16 11:13 ` Ihor Radchenko
2023-01-16 11:52   ` Daniel Kraus
2023-01-16 20:50   ` Tim Cross
2023-01-17  9:42     ` Daniel Kraus
2023-01-17 10:06       ` Supporting non-free SQL clients in ob-sql (was: [PATCH] ob-sql: Add support for Athena) Ihor Radchenko
2023-01-17 11:38         ` Tim Cross
2023-01-23  4:23         ` Richard Stallman
2023-01-23  6:33           ` Jean Louis
2023-01-25  4:31             ` Richard Stallman
2023-01-25  7:57               ` Tim Cross
2023-01-25 12:35                 ` Ihor Radchenko
2023-01-25 14:05                   ` Tim Cross
2023-01-25 14:31                     ` Ihor Radchenko
2023-01-25 21:11                       ` Tim Cross
2023-02-26  2:59                       ` Richard Stallman
2023-01-28  4:45                     ` Richard Stallman
2023-01-30 14:51                       ` Ihor Radchenko
2023-01-28  4:43                 ` Richard Stallman
2023-01-25 11:51               ` Jean Louis
2023-01-29  5:15                 ` Richard Stallman
2023-01-23 12:45           ` Ihor Radchenko
2023-01-23 20:12             ` Tim Cross
2023-01-26  4:25               ` Richard Stallman
2023-01-26  6:59                 ` Supporting non-free SQL clients in ob-sql Loris Bennett
2023-01-26 10:22                 ` Supporting non-free SQL clients in ob-sql (was: [PATCH] ob-sql: Add support for Athena) Ihor Radchenko
2023-01-26 11:05                   ` Supporting non-free SQL clients in ob-sql Heinz Tuechler
2023-01-26 11:14                     ` Ihor Radchenko
2023-01-26 11:47                       ` Heinz Tuechler
2023-01-28  4:45                   ` Supporting non-free SQL clients in ob-sql (was: [PATCH] ob-sql: Add support for Athena) Richard Stallman
2023-01-29 14:21                     ` Ihor Radchenko
2023-02-04  5:15                       ` Richard Stallman
2023-01-26  4:26             ` Richard Stallman

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).