Suppose I have two paths, /data/dev and
/data/prod. When developing, I want to use the dev directory, and in prod I want to use the prod directory.
I need to upload data at some interval (upload_to_tables.sql):
file := :basedir || 'file.csv';
COPY my_table FROM :file WITH (FORMAT csv);
I tried running this, $ environment=dev; psql -d my_database -v basedir="'/data/$environment'" -f upload_to_tables.sql
I get this error:
2019-07-15 09:24:52.302 CDT [90820] ERROR: syntax error at or near "file" at character 1
How can I path the directory from which these data need to be loaded in a dynamic fashion?