Search Postgresql Archives

Re: psql & unix env variables

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

 



On Thu, Aug 30, 2012 at 4:42 PM, Achilleas Mantzios
<achill@xxxxxxxxxxxxxxxxxxx> wrote:
> I have found useful the use of variable assignment in psql, e.g.
>
> #!/bin/sh
>
> # lets say you have some var with a value, or even populate some var with a value from
> # psql as shown below
> somevar=`psql -P pager=off -q -t -c "SELECT foo from bar" | head -1 | sed -e 's/ //g'`
>
> # now use that variable in psql, (what you want to achieve), but in more tight manner
> # than simple shell substitution (see -v switch and : notation)
>
> psql -P pager=off -q -v somevar=$somevar -c "select foo2 from bar2 where var=:somevar"

At this point, I have to ask: Why not switch to a language with actual
Postgres bindings? Try Python, or Pike, or something; I'm sure it's
going to be easier than doing everything through shell scripts.

ChrisA


-- 
Sent via pgsql-general mailing list (pgsql-general@xxxxxxxxxxxxxx)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general


[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 Books]     [PHP Databases]     [Postgresql & PHP]     [Yosemite]
  Powered by Linux