emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* ob-sql is not finding psql when using direnv+guix
@ 2021-05-09  8:07 Adolfo De Unanue
  2021-05-10 18:14 ` Cook, Malcolm
  0 siblings, 1 reply; 7+ messages in thread
From: Adolfo De Unanue @ 2021-05-09  8:07 UTC (permalink / raw)
  To: emacs-orgmode

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

Hi

I am using Guix with direnv. In an specific folder I am installing and using psql and postgresql using direnv+guix as follows:


use guix --manifest=cdpp-manifest.scm

export PGUSER=food_user
export PGPASSWORD=some_password
export PGDATABASE=food

layout postgres


Where cdpp-manifest.scm contains the following:

(specifications->manifest
'("python"
   "python-pandas"
   "python-numpy"
   "python-flask"
   "python-graphene"
   "postgresql"
   "jupyter"))

I am able to use sql-mode and run queries against the database, in order to achieve that I am using the following .dir-locals.el

;;; Directory Local Variables
;;; For more information see (info "(emacs) Directory Variables")


((nil .
      ((projectile-project-test-cmd . "pytest --color=no --failed-first --maxfail=5")))
(python-mode .
              ((python-shell-buffer-name . "Python [CDPP-Inspecciones]")))

(org-mode . (
              (indent-tabs-mode . nil)
              (org-src-preserve-indentation . t)
              (org-footnote-auto-adjust . t)
              (org-footnote-auto-label . t)
              (ispell-local-dictionary . "spanish")
              (org-export-allow-bind-keywords . t)
              (org-footnote-define-inline . nil)
              (org-footnote-section . "Footnotes")))

(sql-mode . ((sql-connection-alist . ((mydb
                                        (sql-product 'postgres)
                                        (sql-database "mydb")
                                        (sql-user "db_user")
                                        (sql-server (expand-file-name ".direnv/postgres"))
                                        (sql-port 5432)
                                        )
                                      )))))

But If I try to use an sql org-babel block

#+begin_src sql
select 1;
#+end_src

(I am setting the connection variables in a PROPERTY)

I get the error: `psql is not found`


I was reading about the variable sql-postgres-program, so if I set the following in dir-locals.el

(sql-postgres-program . "/gnu/store/f2v92bkx2vfzmkl14qxj3hlmby4dy9x0-profile/bin/psql")

It works (note that psql ONLY lives inside the profile defined by direnv+guix), but I don't like the idea of hardcode the path.

Is there a better way?

Ideally I will expect that the org block will read it from the environment, but is not working. 

Thanks in advance

[-- Attachment #2: Type: text/html, Size: 5686 bytes --]

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

end of thread, other threads:[~2021-05-13 23:19 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2021-05-09  8:07 ob-sql is not finding psql when using direnv+guix Adolfo De Unanue
2021-05-10 18:14 ` Cook, Malcolm
2021-05-11 20:54   ` Adolfo De Unanue
2021-05-12 13:49     ` Cook, Malcolm
2021-05-13 17:12       ` org-babel not finding executables when using direnv [Was: Re: ob-sql is not finding psql when using direnv+guix] Adolfo De Unanue
2021-05-13 18:23         ` Cook, Malcolm
2021-05-13 22:54         ` Tim Cross

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).