JaiDécouvert la commande psql nommé \ir :

\ir or \include_relative filename

The \ir command is similar to \i, but resolves relative file names differently. When executing in interactive mode, the two commands behave identically. However, when invoked from a script, \ir interprets file names relative to the directory in which the script is located, rather than the current working directory.

from

J’ai trouvé cette commande via Fwd: psql include file using relative path.

Cela faisait des années que j’avais besoin de cette fonctionnalité et, étrangement, je ne l’ai découverte seulement aujourd’hui 🤔.

Exemple d’utilisation https://github.com/stephane-klein/sklein-pkm-engine/blob/8938d7a2c19ed8f741bd38162882e9517c739c30/sqls/init.sql#L36


Tous les tags présents dans la note :