Re: [GENERAL] psql scripting tutorials

2008-09-20 Thread Michelle Konzack
Am 2008-09-11 10:03:03, schrieb Roderick A. Anderson: Whatever happened to pgbash? I see the last update was Feb 2003 but that was for Pg v7.3. I have tried it soe times ago with 7.4 but goten to many errors... ...and gaved up. Thanks, Greetings and nice Day/Evening Michelle Konzack

Re: [GENERAL] psql scripting tutorials

2008-09-12 Thread Peter Eisentraut
Alvaro Herrera wrote: Doesn't say about variable expansion ... And it seems to be in a different realm, because the point is that the command is going to have a single destination (either \-processing or sending it to the server). Is psql being just lazy here and avoiding parsing the command?

Re: [GENERAL] psql scripting tutorials

2008-09-12 Thread Blazej
Ok then. Does anyone have any tips or best practices for scripting psql? I'll probably write some bash scripts to pull csv files over then script psql to do a COPY into an import schema then run a pl/pgsql procedure, er function, to do all ETL. Who else is doing something like this? Can

Re: [GENERAL] psql scripting tutorials

2008-09-11 Thread Harald Fuchs
In article [EMAIL PROTECTED], Greg Smith [EMAIL PROTECTED] writes: On Tue, 9 Sep 2008, Artacus wrote: Can psql access environmental variables or command line params? $ cat test.sql select :TEST as input; $ psql -v TEST=16 -f test.sql input --- 16 (1 row) Nice trick, but when I

Re: [GENERAL] psql scripting tutorials

2008-09-11 Thread Alvaro Herrera
Harald Fuchs escribió: Nice trick, but when I try the following variant: psql -v TEST=16 -c 'select :TEST as input' I get ERROR: syntax error at or near : LINE 1: select :TEST as input This seems to be contrary to the psql manual page: These assignments are done during a

Re: [GENERAL] psql scripting tutorials

2008-09-11 Thread Peter Eisentraut
Harald Fuchs wrote: In article [EMAIL PROTECTED], Greg Smith [EMAIL PROTECTED] writes: On Tue, 9 Sep 2008, Artacus wrote: Can psql access environmental variables or command line params? $ cat test.sql select :TEST as input; $ psql -v TEST=16 -f test.sql input --- 16 (1 row) Nice

Re: [GENERAL] psql scripting tutorials

2008-09-11 Thread Alvaro Herrera
Peter Eisentraut escribió: psql manual page: -c command --command command Specifies that psql is to execute one command string, command, and then exit. This is useful in shell scripts. command must be either a command string that is completely

Re: [GENERAL] psql scripting tutorials

2008-09-11 Thread Kevin Hunter
At 7:13am -0400 on Thu, 11 Sep 2008, Harald Fuchs wrote: Nice trick, but when I try the following variant: psql -v TEST=16 -c 'select :TEST as input' I get [a syntax error] This seems to be contrary to the psql manual page: Nope. Take a look at the -c option. Specifically Thus you

Re: [GENERAL] psql scripting tutorials

2008-09-11 Thread Roderick A. Anderson
Kevin Hunter wrote: At 7:13am -0400 on Thu, 11 Sep 2008, Harald Fuchs wrote: Nice trick, but when I try the following variant: psql -v TEST=16 -c 'select :TEST as input' I get [a syntax error] This seems to be contrary to the psql manual page: Nope. Take a look at the -c option.

Re: [GENERAL] psql scripting tutorials

2008-09-11 Thread Adrian Klaver
-- Original message -- From: Roderick A. Anderson [EMAIL PROTECTED] Kevin Hunter wrote: At 7:13am -0400 on Thu, 11 Sep 2008, Harald Fuchs wrote: Nice trick, but when I try the following variant: psql -v TEST=16 -c 'select :TEST as input' I get [a

Re: [GENERAL] psql scripting tutorials

2008-09-11 Thread Artacus
$ TEST=16; psql -c select $TEST as \input1\; $ TEST=16; echo select $TEST as \input1\; | psql Yep that works. My coworker also suggested using EOF to simulate a psql script. -- Sent via pgsql-general mailing list (pgsql-general@postgresql.org) To make changes to your subscription:

Re: [GENERAL] psql scripting tutorials

2008-09-10 Thread Artacus
Artacus wrote: I'd like to learn a little more about writing psql scripts does anyone know of any resources outside of the manual? Ok then. Does anyone have any tips or best practices for scripting psql? I'll probably write some bash scripts to pull csv files over then script psql to do a

Re: [GENERAL] psql scripting tutorials

2008-09-10 Thread John DeSoi
On Sep 10, 2008, at 2:46 AM, Artacus wrote: Who else is doing something like this? Can psql access environmental variables or command line params? Or do I have to have my bash script write a psql script every time? The psql \! command can execute shell commands. You can also use ``,

Re: [GENERAL] psql scripting tutorials

2008-09-10 Thread Scott Marlowe
On Wed, Sep 10, 2008 at 12:46 AM, Artacus [EMAIL PROTECTED] wrote: Artacus wrote: I'd like to learn a little more about writing psql scripts does anyone know of any resources outside of the manual? Ok then. Does anyone have any tips or best practices for scripting psql? I'll probably write

Re: [GENERAL] psql scripting tutorials

2008-09-10 Thread Artacus
This sounds a lot like what I did in my last job using bash for most things, and php for the more complicated stuff. Wrote a simple oracle to pgsql table replicator in php that worked pretty well. Well we do this stuff all the time with Oracle and sql*plus. And I've heard people hear say

Re: [GENERAL] psql scripting tutorials

2008-09-10 Thread Scott Marlowe
On Wed, Sep 10, 2008 at 10:14 PM, Artacus [EMAIL PROTECTED] wrote: This sounds a lot like what I did in my last job using bash for most things, and php for the more complicated stuff. Wrote a simple oracle to pgsql table replicator in php that worked pretty well. Well we do this stuff all

Re: [GENERAL] psql scripting tutorials

2008-09-10 Thread Greg Smith
On Tue, 9 Sep 2008, Artacus wrote: Can psql access environmental variables or command line params? $ cat test.sql select :TEST as input; $ psql -v TEST=16 -f test.sql input --- 16 (1 row) You can find out more about what you can do with variable substitution at

[GENERAL] psql scripting tutorials

2008-09-07 Thread Artacus
I'd like to learn a little more about writing psql scripts does anyone know of any resources outside of the manual? -- Sent via pgsql-general mailing list (pgsql-general@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-general