Re: python script for crosstab queries in PostgreSQL

From: "scott(dot)marlowe" <scott(dot)marlowe(at)ihs(dot)com>
To: Andrew Gould <andrewgould(at)yahoo(dot)com>
Cc: Postgres Mailing List <pgsql-general(at)postgresql(dot)org>
Subject: Re: python script for crosstab queries in PostgreSQL
Date: 2003-06-26 18:14:17
Message-ID: Pine.LNX.4.33.0306261213270.1254-100000@css120.ihs.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

If it's only 3k in size, you could probably post it here as an attachment.
Heck, there're discussion threads with text that size in them all the
time. 8-)

On Thu, 26 Jun 2003, Andrew Gould wrote:

> I just finished a python script that performs a
> crosstab query in PostgreSQL. Since I do most of my
> analysis using MS Access, this was more of an academic
> excercise than anything else.
>
> I wrote the script externally to PostgreSQL using
> PyGreSQL because:
>
> 1. The script can be copied and saved as different
> queries; and
> 2. I'm am, admittedly, squeamish about new languages
> and compiling additional features into any
> application. (There is no 'IS' in 'CPA').
>
> The script has the following features/limitations:
>
> 1. The user defines all database connection and query
> variables near the top of the file.
> 2. The script builds the sql query from defined
> variables.
> 3. SELECT INTO is used to store the result set in a
> table. There is a variable to make the table
> temporary.
> 4. The script does not allow for joining tables.
> 5. You can only use values from one column for
> crosstab column headers.
> 6. I haven't learned about handling errors yet.
>
> Limitations 4 and 5 can be worked around, I've done
> both in MS Access; but the opportunity for errors was
> too great for the first run.
>
> As for #6, I wasn't interested in making errors! ;-)
> (Yes, I know....I'll add error handling to my
> 'learning' list.)
>
> If anyone is interested in the script, let me know.
> It's under 3K in size.
>
> Andrew Gould
>
> ---------------------------(end of broadcast)---------------------------
> TIP 6: Have you searched our list archives?
>
> http://archives.postgresql.org
>

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Paul Ramsey 2003-06-26 18:17:47 Re: [GENERAL] pg_dump "all tables" in 7.3.X
Previous Message Andrew Gould 2003-06-26 18:14:05 Re: pg_dump "all tables" in 7.3.X