Output normalised diffable database schemas
Project description
Diffable SQL
This is a small tool that outputs SQL from a number of databases in a sorted, diff-friendly order.
Install
The tool supports any database that SQLAlchemy supports. You must install the correct connector for your database:
$ pip install diffable-sql
$ pip install psycopg2-binary # postgres
$ pip install mysqlclient # mysql
Usage
You can pass any number of DSNs as arguments, for example postgresql:///db-name
. The tool will output normalised SQL
DDL statements for each DSN.
$ diffable-sql sqlite:///db.sqlite3
CREATE TABLE sometable (
foo VARCHAR,
id BIGINT NOT NULL
);
ALTER TABLE sometable ADD CONSTRAINT c PRIMARY KEY (id);
ALTER TABLE sometable ADD CONSTRAINT c UNIQUE (foo);
CREATE INDEX i ON sometable (foo);
Specifically:
- The tables and columns will be sorted by name
- Indexes and constraints will be renamed as
i
andc
- Deferrable constraint information will be hidden
- Identity columns will be hidden
These allow schemas to be more easily diffed.
Args
$ diffable-sql --help
Usage: diffable-sql [OPTIONS] [dsn]...
Options:
--no-rename-indexes TEXT Don't rename indexes
--no-rename-constraints TEXT Don't rename constraints
--no-ignore-deferrable-constraints TEXT
Include deferrable constraint information
--no-ignore-identity-columns TEXT
Don't ignore identity column information
--help Show this message and exit.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
diffable_sql-0.1.1.tar.gz
(2.5 kB
view hashes)
Built Distribution
Close
Hashes for diffable_sql-0.1.1-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 1aa7148f9ed2578beb7a224bd72f72c5eaea48295d841a13efbcc2216fe21fc6 |
|
MD5 | bd85e01162f0dae21732135e36f78065 |
|
BLAKE2b-256 | 7083f951d5a5ffd5c0b89e6d72ae9a7bf44bb969b10784636a6f85bacf029da4 |