sql_insert_writer v0.1.0

Catherine Devlin <[email protected]>
Newsgroups gmane.comp.db.postgresql.announce
Message-ID <CAGCtaoPiGf-Ls6QosnLTrkPy7WAUuXUiWvvOf85e3z0a0teJ0Q@mail.gmail.com>
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/
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.