emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: Jakob Lombacher <Jakob@lombacher.net>
To: Emacs-orgmode@gnu.org
Subject: custom port for postgresql
Date: Wed, 7 Sep 2016 20:53:46 +0200	[thread overview]
Message-ID: <CALAc-BuHZW1CJ2Rf3=np=O1=xO0K5d6nuUg-zk54jNmDTB0cnA@mail.gmail.com> (raw)


[-- Attachment #1.1: Type: text/plain, Size: 226 bytes --]

Hi,

I wondered why I couldn't connect to my database, and I figured out that a
custom port is not supported as header argument for postgresql.

I don't know how the merging in this project works, so here is the patch.

Jakob

[-- Attachment #1.2: Type: text/html, Size: 327 bytes --]

[-- Attachment #2: 0001-port-added-to-psql.patch --]
[-- Type: text/x-patch, Size: 1348 bytes --]

From 9043307466cabdf7d6c6fa2534c39ad00d42b522 Mon Sep 17 00:00:00 2001
From: Jakob Lombacher <Jakob@Lombacher.net>
Date: Wed, 31 Aug 2016 22:11:57 +0200
Subject: [PATCH] port added to psql

---
 lisp/ob-sql.el | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/lisp/ob-sql.el b/lisp/ob-sql.el
index 7801c5f..25187a3 100644
--- a/lisp/ob-sql.el
+++ b/lisp/ob-sql.el
@@ -90,12 +90,13 @@
 	       (when password (concat "-p" password))
 	       (when database (concat "-D" database))))))
 
-(defun org-babel-sql-dbstring-postgresql (host user database)
+(defun org-babel-sql-dbstring-postgresql (host port user database)
   "Make PostgreSQL command line args for database connection.
 Pass nil to omit that arg."
   (combine-and-quote-strings
    (delq nil
 	 (list (when host (concat "-h" host))
+	       (when port     (format "-p%d" port))
 	       (when user (concat "-U" user))
 	       (when database (concat "-d" database))))))
 
@@ -171,7 +172,7 @@ This function is called by `org-babel-execute-src-block'."
 footer=off -F \"\t\"  %s -f %s -o %s %s"
 				  (if colnames-p "" "-t")
 				  (org-babel-sql-dbstring-postgresql
-				   dbhost dbuser database)
+				   dbhost dbport dbuser database)
 				  (org-babel-process-file-name in-file)
 				  (org-babel-process-file-name out-file)
 				  (or cmdline "")))
-- 
2.9.3


             reply	other threads:[~2016-09-07 18:53 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-09-07 18:53 Jakob Lombacher [this message]
2016-09-14  5:04 ` custom port for postgresql Adam Porter

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.orgmode.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='CALAc-BuHZW1CJ2Rf3=np=O1=xO0K5d6nuUg-zk54jNmDTB0cnA@mail.gmail.com' \
    --to=jakob@lombacher.net \
    --cc=Emacs-orgmode@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).