PivotMyTable is a PL/Python PosgreSQL function for easy construction of pivot tables, generating the proper code for the crosstab functions from the PostgreSQL extension tablefunc to work.
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
example_data
LICENSE
README.md
pivotmytable.sql

README.md

PivotMyTable

PivotMyTablee is a PL/Python function for use in PostgreSQL servers. Its aim is to get crosstab/pivoted tables in a more friendly way that PostgreSQL module tablefunc does with its crosstab series functions and in fact it behaves ,at last, as a proxy for tablefunc functions.

PivotMyTablee makes it possible in the same way that other available solutions, automating the creation of the queries that the tablefunc crosstab functions need to work.

Also, PivotMyTablee makes possible to directly get percentages in the pivoted tables, as well as get rid of null values in the oputput tables.

Copyright/License

PivotMyTable has been developed by Jorge Tornero.

(C) 2014 Jorge Tornero, http://imasdemase.com

PivotMyTable is released under the terms of the

GNU GENERAL PUBLIC LICENSE

Version 3, 29 June 2007

This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program. If not, see:

http://www.gnu.org/licenses

Donations/Fees

Of course, no donations or fees are required for using PivotMyTable in your databases/servers... but if you feel that PivotMyTable has improved you life in any way, you can make a small donation to a NGO/Charity of your choice.

Additionally, if you really feel in the mood of rewarding me, just feel free for asking me about my postal address and send me a postcard from where you live. I'll be proud of showing it to my kid.

Changelog

2014/03/18

  • Added support for table output.
  • Added provisional normalization of parameters to avoid problems with spaces.

2015/05/31 This changes thanks to @JohnDeGitt

  • Use pg_attribute (Postgresql catalog table) instead of information_schema to get metadata on Postgresql relations. It is faster and contains details about all relations: tables, views and materialized views.
  • Use current_schema() as a relation name prefix to make sure that it refers current schema (the same names can exist in different schemas).

Installation and usage

Please visit my page about PivotMyTable here. You can find a SQL script which creates a table with the sample data under the folder example_data of this repository.