Search Postgresql Archives

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

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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.





[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Postgresql Jobs]     [Postgresql Admin]     [Postgresql Performance]     [Linux Clusters]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Databases]     [Postgresql & PHP]     [Yosemite]

  Powered by Linux