0

I am setting up an org-mode document to connect to a postgreSQL database and execute+show the results of some queries. I don't want the database password visible in the org document (regardless of whether the document is exported: I want to be able to share the raw .org file without having to worry about the password).

I saved the password to my emacs environment with setenv. I know I can reference it in an emacs-lisp block with getenv. Is there any way I can use this in an org babel header argument?

I have the following header arguments:

* Setting Up Database Connection Details
:PROPERTIES:
:header-args:sql: :engine postgres :dbuser MyUserName
:header-args:sql+: :database MyDatabaseName
:header-args:sql+: :dbpassword # [want to reference env variable here]
:header-args:sql+: :dbhost HostName
:END:

This works fine—I'm able to access the database and execute queries with the password copied in explicitly. But I'd like to replace it with a reference to the environment variable.

2
  • I take it that you've tried :header-args:sql+: :dbpassword (getenv "PASSWORD") and it does not work?
    – NickD
    Jun 3 at 14:34
  • correct! I have tried that, and it did not work.
    – dlid
    Jun 3 at 14:57

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.