gmr / pgparse

Python wrapper for libpg_query

Home Page:https://pgparse.readthedocs.io

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

pgparse

Python wrapper for libpg_query

Package Version Code Coverage BSD Documentation Status

Installation

pip install pgparse

Example Usage

The following example shows how to create a dump and then read it in, and iterate through the data of one of the tables.

import pprint

import pgparse

sql = "SELECT * FROM pg_catalog.pg_class WHERE relname = 'foo'"
print('Fingerprint: {}'.format(pgparse.fingerprint(sql)))
print('Normalized: {!r}'.format(pgparse.normalize(sql)))
parsed = pgparse.parse(sql)
pprint.pprint(parsed)

func = """\
CREATE FUNCTION sales_tax(subtotal real) RETURNS real AS $$
        BEGIN
            RETURN subtotal * 0.06;
        END;
        $$ LANGUAGE plpgsql;
"""
parsed = pgparse.parse_pgsql(func)
pprint.pprint(parsed)

About

Python wrapper for libpg_query

https://pgparse.readthedocs.io

License:BSD 3-Clause "New" or "Revised" License


Languages

Language:Python 96.4%Language:Shell 3.6%