Обсуждение: [ANNOUNCE] sql_insert_writer v0.1.0

Поиск
Список
Период
Сортировка

[ANNOUNCE] sql_insert_writer v0.1.0

От
Catherine Devlin
Дата:
Announcing sql_insert_writer, a Python3 utility to build skeletons for INSERT and INSERT FROM statements, with explicit target column lists and clarifying comments.


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