From: | Ivan Sergio Borgonovo <mail(at)webthatworks(dot)it> |
---|---|
To: | <pgsql-general(at)postgresql(dot)org> |
Subject: | Re: bash & postgres |
Date: | 2009-03-23 08:09:42 |
Message-ID: | 20090323090942.5f970f32@dawn.webthatworks.it |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general pgsql-sql |
On Mon, 23 Mar 2009 15:03:15 +1100
Greenhorn <user(dot)postgresql(at)gmail(dot)com> wrote:
> Hi,
>
> I'm trying to pass variables on a bash script embedded with psql
> commands.
>
> cat header.txt
>
> "to1","from1","subject1"
> "to2","from2","subject2"
> "to3","from3","subject3"
> "to4","from4","subject4"
>
> cat b.sh
>
> #!/bin/bash
> two="2"
>
> psql -h localhost -U postgres -d mobile -c "create temp table
> header (
I enjoy another technique that's not exactly embedding but makes the
sql file easily executable from other shells to and easier to
maintain (eg. you don't lose syntax highlight, you don't need to
make wide use of x bit, you can concatenate files...).
echo "select :a;" | psql --set a=3 test
?column?
----------
3
(1 row)
of course in spite of piping your sql, you could put it into a file.
--
Ivan Sergio Borgonovo
http://www.webthatworks.it
From | Date | Subject | |
---|---|---|---|
Next Message | Ivan Sergio Borgonovo | 2009-03-23 08:33:36 | Re: text column constraint, newbie question |
Previous Message | David Wilson | 2009-03-23 07:51:59 | Re: text column constraint, newbie question |
From | Date | Subject | |
---|---|---|---|
Next Message | Achilleas Mantzios | 2009-03-23 08:15:11 | Re: cast bool/int |
Previous Message | Zdravko Balorda | 2009-03-23 07:59:12 | cast bool/int |