Skip to main content

Makes your SQL readable.

Project description

https://travis-ci.org/paetzke/format-sql.svg?branch=master https://coveralls.io/repos/paetzke/format-sql/badge.svg?branch=master https://badge.fury.io/py/format-sql.svg

Makes your SQL readable.

https://paetzke.me/static/images/format-sql.gif

An example:

    sql = """ SELECT country, product, SUM(profit) FROM
sales   left join x on x.id=sales.k GROUP BY country,
product having f > 7 and fk=9 limit 5;    """

Will result in:

sql = """
    SELECT
        country,
        product,
        SUM(profit)
    FROM
        sales
        LEFT JOIN x ON
            x.id = sales.k
    GROUP BY
        country,
        product
    HAVING
        f > 7
        AND fk = 9
    LIMIT 5; """

Install format-sql via pip:

$ pip install format-sql

You can then just call format-sql with files and directories:

$ format-sql -h
usage: format-sql [-h] [--types TYPES] [-r] [--no-semicolon] [--version]
                  [--debug] [--dry-run]
                  paths [paths ...]

positional arguments:
  paths

optional arguments:
  -h, --help       show this help message and exit
  --types TYPES    Only process these given file types.
  -r, --recursive  Process files found in subdirectories.
  --no-semicolon   Try to detect SQL queries with no trailing semicolon.
  --version        show program's version number and exit
  --debug          Print available debug information.
  --dry-run        Print the altered output and do not change the file.

For example:

$ format-sql my-file.py

Or recursively with directory:

$ format-sql -r my-directory/

You can try format-sql online: http://format-sql.de.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

format-sql-0.9.0.tar.gz (11.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

format_sql-0.9.0-py2.py3-none-any.whl (14.7 kB view details)

Uploaded Python 2Python 3

File details

Details for the file format-sql-0.9.0.tar.gz.

File metadata

  • Download URL: format-sql-0.9.0.tar.gz
  • Upload date:
  • Size: 11.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for format-sql-0.9.0.tar.gz
Algorithm Hash digest
SHA256 e7bcbf6b347a02c32cc6090ea64b4246af378743f629494d0f97d3574a6f4226
MD5 31da525d96d90ac070d391aa756884e1
BLAKE2b-256 458f4f4a74127f4ec746f12eb4db6647b76e36dde4c54c98324e5d042ff2712d

See more details on using hashes here.

File details

Details for the file format_sql-0.9.0-py2.py3-none-any.whl.

File metadata

File hashes

Hashes for format_sql-0.9.0-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 7c8a70467ab415f0423cdf628c2aebb75e3e312574bb68048bbcc72c47a0506d
MD5 2b5c43afaf544fda4f748ad3270a48a7
BLAKE2b-256 79f342a29804ec930c0d60adcd3a96c88796191cb78dabb465194b6f4e9fde91

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page