sql_insert_writer v0.1.0

From: Catherine Devlin <catherine(dot)devlin(at)gmail(dot)com>
To: pgsql-announce(at)postgresql(dot)org
Subject: sql_insert_writer v0.1.0
Date: 2017-10-12 21:18:18
Message-ID: CAGCtaoPiGf-Ls6QosnLTrkPy7WAUuXUiWvvOf85e3z0a0teJ0Q@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-announce

Announcing sql_insert_writer, a Python3 utility to build skeletons for
INSERT and INSERT FROM statements, with explicit target column lists and
clarifying comments.

https://github.com/18F/sql_insert_writer

Usage example (assumes that the `pip` package manager has been installed,
and a local database `zoo` with tables `pet`, `animal`)

$ pip install sql-insert-writer psycopg2
$ export DATABASE_URL=postgresql:///zoo
$ sql_insert_writer pet

INSERT INTO pet (
id,
name,
species_name,
planet,
kg
)
VALUES
(
DEFAULT, -- ==> id
DEFAULT, -- ==> name
DEFAULT, -- ==> species_name
DEFAULT, -- ==> planet
DEFAULT -- ==> kg
)

$ sql_insert_writer pet animal

INSERT INTO pet (
id,
name,
species_name,
planet,
kg
)
SELECT
id, -- ==> id
name, -- ==> name
species_name, -- ==> species_name
planet, -- ==> planet
DEFAULT -- ==> kg
FROM animal

--
- Catherine @ 18F
https://18f.gsa.gov/

Browse pgsql-announce by date

  From Date Subject
Next Message Daniele Varrazzo 2017-10-13 11:10:00 pg_repack 1.4.2 released
Previous Message Monica Real Amores 2017-10-11 09:33:25 repmgr v4.0 Beta Now Available