Re: Script checking to see what database it's connected to

From: Ron <ronljohnsonjr(at)gmail(dot)com>
To: pgsql-general(at)lists(dot)postgresql(dot)org
Subject: Re: Script checking to see what database it's connected to
Date: 2021-02-22 01:03:41
Message-ID: 3fb4572b-bd20-5000-38eb-51429c0e3d7a@gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

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, yet so earnestly want avoid Yet Another Tiny Script.
>>
> Isn't it a toss-up with putting the check in every sql script?

I was hoping to "\include" that at the top of each script, since doing that
once is easier than remembering to use the script each time.

> Or make it /really/ fancy: use proper arg parsing; check for existence of
> the sql script;  add a usage function; split stdout/stderr...  No end of fun.

--
Angular momentum makes the world go 'round.

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Julien Rouhaud 2021-02-22 01:19:37 Re: Script checking to see what database it's connected to
Previous Message Tim Cross 2021-02-22 01:01:49 Re: Script checking to see what database it's connected to