Hello there, thanks for Org Mode! ob-sql.el has a function org-babel-execute:sql. This function extracts the password to connect to your database of choice as dbpassword. It then uses it like this:
(if dbpassword (format "PGPASSWORD=%s " dbpassword) "") If the password contains an & character, the execution of a block fails. I solved like this: (if dbpassword (format "PGPASSWORD='%s' " dbpassword) "") Hope this is of help, Andrea Emacs : GNU Emacs 29.3 (build 1, x86_64-pc-linux-gnu, GTK+ Version 3.24.33, cairo version 1.16.0) of 2024-03-26, modified by Debian Package: Org mode version 9.7.3 (9.7.3-2f1844 @ /home/andrea/.emacs.d/elpa/org-9.7.3/)