python script for crosstab queries in PostgreSQL

Поиск
Список
Период
Сортировка
От Andrew Gould
Тема python script for crosstab queries in PostgreSQL
Дата
Msg-id 20030626181232.31542.qmail@web13408.mail.yahoo.com
обсуждение исходный текст
Ответы Re: python script for crosstab queries in PostgreSQL  ("scott.marlowe" <scott.marlowe@ihs.com>)
Список pgsql-general
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

В списке pgsql-general по дате отправления:

Предыдущее
От: Tom Lane
Дата:
Сообщение: Re: pg_dump "all tables" in 7.3.X
Следующее
От: "scott.marlowe"
Дата:
Сообщение: Re: MS Access, pgsqlODBC and PostgreSQL in Linux via