emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: "Cook, Malcolm" <MEC@stowers.org>
To: Adolfo De Unanue <adolfo+org@unanue.mx>,
	"emacs-orgmode@gnu.org" <emacs-orgmode@gnu.org>
Subject: RE: ob-sql is not finding psql when using direnv+guix
Date: Mon, 10 May 2021 18:14:24 +0000	[thread overview]
Message-ID: <DM6PR20MB34104E23855EEEE916722E57BE549@DM6PR20MB3410.namprd20.prod.outlook.com> (raw)
In-Reply-To: <3d3611c4-17a6-4d55-875b-f566c28d297b@www.fastmail.com>

>I am using Guix with direnv.

What is your shell?

How/When do you "hook direnv into your shell" (https://direnv.net/)?

> 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

When are you doing this?

 a) in the "specific folder"'s .envrc file?
 b) in an org-mode shell block that you execute prior to the sql block?
 c) ??

You seem to be following [Per\-project Postgres](https://jamey.thesharps.us/2019/05/29/per-project-postgres/) but with guix instead of nix.  Nice.

If you enter the directory and then call emacs, earthing should just work, no changes neede.

If you want to tell emacs to adopt the environment established by a .direnv, you probably want [direnv integration for emacs\.](https://github.com/wbolster/emacs-direnv)

I've got to try this!


>Where cdpp-manifest.scm contains the following:
>   "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;
>(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

  reply	other threads:[~2021-05-10 18:16 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
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 [this message]
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

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:

  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=DM6PR20MB34104E23855EEEE916722E57BE549@DM6PR20MB3410.namprd20.prod.outlook.com \
    --to=mec@stowers.org \
    --cc=adolfo+org@unanue.mx \
    --cc=emacs-orgmode@gnu.org \


* 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


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