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

From: Rob Sargent <robjsargent(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 00:49:33
Message-ID: 5e45b234-9390-e394-dc31-4dc3f7dbffdc@gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

>>
>> 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?
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.

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Ron 2021-02-22 01:00:20 Re: Script checking to see what database it's connected to
Previous Message Ron 2021-02-22 00:42:50 Re: Script checking to see what database it's connected to