format-sql is a tool to format SQL in your Python strings!
Project description
format-sql is a tool to format SQL in your Python strings!
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 [TYPES ...]]] [-r] [--no-semicolon]
paths [paths ...]
positional arguments:
paths
optional arguments:
-h, --help show this help message and exit
--types [TYPES [TYPES ...]]
Process given file types. Default value is "py".
-r, --recursive Process files found in subdirectories.
--no-semicolon Try to detect SQL queries with no trailing semicolon.
Changes
0.1
Add parameter --no-semicolon to enable taking SQL queries without semicolon into account.
Copyright (c) 2014, Friedrich Paetzke (paetzke@fastmail.fm). All rights reserved.
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
format-sql-0.1.0.tar.gz
(7.1 kB
view hashes)
Built Distribution
Close
Hashes for format_sql-0.1.0-py2.py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 37b60ae3e68fb040cf0bd2d9b3e504cdd81c3e6ff238306f9b70303bbcf35802 |
|
MD5 | 0b7346dffbfe7f5d42512e911629a134 |
|
BLAKE2b-256 | 4c5bf81f4a0208947b4bbcc0276051e6d5d1ef27e21d46db6b769e3a6db4134a |