Skip to main content

Makes your SQL readable.

Project description

Makes your SQL readable.

An example:

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

Will result in:

sql = """
        LEFT JOIN x ON
   = sales.k
        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:

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

Or recursively with directory:

$ format-sql -r my-directory/

You can try format-sql online:

Download files

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

Files for format-sql, version 0.12.0
Filename, size File type Python version Upload date Hashes
Filename, size format_sql-0.12.0-py2.py3-none-any.whl (14.9 kB) File type Wheel Python version 3.4 Upload date Hashes View
Filename, size format-sql-0.12.0.tar.gz (12.3 kB) File type Source Python version None Upload date Hashes View

Supported by

AWS AWS Cloud computing Datadog Datadog Monitoring DigiCert DigiCert EV certificate Facebook / Instagram Facebook / Instagram PSF Sponsor Fastly Fastly CDN Google Google Object Storage and Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Salesforce Salesforce PSF Sponsor Sentry Sentry Error logging StatusPage StatusPage Status page