Re: postgres via shell scripts - Mailing list pgsql-general

From Billy G. Allie
Subject Re: postgres via shell scripts
Date
Msg-id 200010070037.e970btk23397@bajor.mug.org
Whole thread Raw
In response to postgres via shell scripts  (Mike Sears <msears@vianet.ca>)
List pgsql-general
Mike Sears wrote:
> Is there away to access a postgres database using a shell script, like bash
> or korn?
>
> Mike
>

The solution I came up with to access a database (originally Sybase, the later
msql and PostgreSQL) from the shell (sh, ksh) and awk was to write a program
(called getsql) that accepted SQL statements from stdin and wrote the result
to stdout as delimited fields (the default was the bar [|] character).  I
would then create 2 named pipes and run getsql in the background reading from
one named pipe and writing to the other named pipe.  The program that needed
access (sh, ksh, awk, etc) would then write queries to the named pipe that
getsql was reading from and get the results from the named pipe getsql writes
to.

If you are interested, I can send you the source code for getsql, or if there
is enough interest, I can post the code to the list.
--
____       | Billy G. Allie    | Domain....: Bill.Allie@mug.org
|  /|      | 7436 Hartwell     | Compuserve: 76337,2061
|-/-|----- | Dearborn, MI 48126| MSN.......: B_G_Allie@email.msn.com
|/  |LLIE  | (313) 582-1540    |



Attachment

pgsql-general by date:

Previous
From: "Efrain Caro"
Date:
Subject: Delphi PostgreSQL Forum
Next
From: "Franz J Fortuny"
Date:
Subject: Advise requested and suggestions welcome