Julien Rouhaud schrieb am 22.02.2021 um 02:19:
>> The output:
>> $ psql12 -f test_pg.sql
>> t
>> connected to postgres
>> got here
>> psql:test_pg.sql:15: ERROR: syntax error at or near "exit"
>> LINE 1: exit
>
> Well, the supported commands did work. You should probably look at
> https://www.pos
On 2/21/21 7:19 PM, Julien Rouhaud wrote:
[snip]
Well, the supported commands did work. You should probably look at
https://www.postgresql.org/docs/current/app-psql.html, you'd see that
"exit" is not a supported command and you should instead use \q[uit].
I recommend looking at the semantics of
On Mon, Feb 22, 2021 at 9:00 AM Ron wrote:
>
> On 2/21/21 5:26 PM, Julien Rouhaud wrote:
>
> On Mon, Feb 22, 2021 at 7:19 AM Ron wrote:
>
> Thus, I want to add a bit to the top of the script, something like this:
>
> \if :DBNAME = postgres
> echo "must not run in postgres"
> exit
> \end
Rob Sargent writes:
>>>
>>> Take it up a notch? Write a script which takes the dbname and the
>>> script name:
>>>
>>> /pcode/
>>>
>>> #!/bin/bash -e
>>> if [[ $# -ne 2 ]]; then echo "missing arg(s)"; exit 2; fi
>>> dbn=$1; shift;
>>> sql=$1; shift;
>>> psql --dbname $dbn --file $sql
>>>
>>> /
On 2/21/21 6:49 PM, Rob Sargent wrote:
Take it up a notch? Write a script which takes the dbname and the
script name:
/pcode/
#!/bin/bash -e
if [[ $# -ne 2 ]]; then echo "missing arg(s)"; exit 2; fi
dbn=$1; shift;
sql=$1; shift;
psql --dbname $dbn --file $sql
/pcode/
I thought of that
On 2/21/21 5:26 PM, Julien Rouhaud wrote:
On Mon, Feb 22, 2021 at 7:19 AM Ron wrote:
Thus, I want to add a bit to the top of the script, something like this:
\if :DBNAME = postgres
echo "must not run in postgres"
exit
\endif
However, I can't seem to find the magic sauce.
You have
Take it up a notch? Write a script which takes the dbname and the
script name:
/pcode/
#!/bin/bash -e
if [[ $# -ne 2 ]]; then echo "missing arg(s)"; exit 2; fi
dbn=$1; shift;
sql=$1; shift;
psql --dbname $dbn --file $sql
/pcode/
I thought of that, yet so earnestly want avoid Yet Anoth
On 2/21/21 5:26 PM, Rob Sargent wrote:
On 2/21/21 4:18 PM, Ron wrote:
Postgresql 12.5
I've got scripts which can run on multiple database (dev, test, QA,
Integration, Training, etc, etc), so of course I've got to run them like
"psql my_db_name -f script.sql".
Of course, I sometimes forge
On 2/21/21 4:18 PM, Ron wrote:
Postgresql 12.5
I've got scripts which can run on multiple database (dev, test, QA,
Integration, Training, etc, etc), so of course I've got to run them like
"psql my_db_name -f script.sql".
Of course, I sometimes forget to specify the database name, and so
On Mon, Feb 22, 2021 at 7:19 AM Ron wrote:
>
> Thus, I want to add a bit to the top of the script, something like this:
>
> \if :DBNAME = postgres
> echo "must not run in postgres"
> exit
> \endif
>
> However, I can't seem to find the magic sauce.
You have to use a dedicated variable.
Postgresql 12.5
I've got scripts which can run on multiple database (dev, test, QA,
Integration, Training, etc, etc), so of course I've got to run them like
"psql my_db_name -f script.sql".
Of course, I sometimes forget to specify the database name, and so it fails.
Thus, I want to add a b
11 matches
Mail list logo