sqlint
This is a SQL parser and linter for Standard SQL(BigQuery).
https://github.com/shigeru0215/sqlint
Install
$ pip install sqlint
Usage
linting
$ cat example.sql
>> select
>> a + b as x
>> , b+c as y
>> from
>> test_table as t1
$ sqlint example.sql
>> example.sql (L3, 8): whitespace must be before binary operator: b+
>> example.sql (L3, 8): whitespace must be after binary operator: +c
formatting
With -f option, this linter show formatted SQL.
$ sqlint -f query/example.sql
>> select
>> a + b as x
>> , b + c as y
>> from
>> test_table as t1
REPL
$ python
>>> from sqlint import parse, check, format
>>> sql = 'SELECT id From user_table where user_table.age >10'
>>>
>>> parse(sql)
[[<Keyword: 'SELECT'>, <Whitespace: ' '>, <Identifier: 'id'>, <Whitespace: ' '>, <Keyword: 'From'>, <Whitespace: ' '>, <Identifier: 'user_table'>, <Whitespace: ' '>, <Keyword: 'where'>, <Whitespace: ' '>, <Identifier: 'user_table.age'>, <Whitespace: ' '>, <Operator: '>'>, <Identifier: '10'>]]
>>>
>>> check(sql)
['(L1, 1): reserved keywords must be lower case: SELECT -> select', '(L1, 11): reserved keywords must be lower case: From -> from', '(L1, 26): too many spaces', '(L1, 49): whitespace must be after binary operator: >10']
>>>
>>> format(sql)
>>> select
>>> id
>>> from
>>> user_table
>>> where
>>> user_table.age > 10
Release files for sqlint 0.2.4
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| sqlint-0.2.4.tar.gz | 22.4 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| sqlint-0.2.4-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 50.4 kB
Release files / sqlint-0.2.4.tar.gz
| Download URL | sqlint-0.2.4.tar.gz |
|---|---|
| Size | 22.4 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
5ca49c335d8f3fdc00d01496760b7e0a2a830c7dec789673f1c771f9e7086020
|
|
BLAKE2b-256 checksum How to use checksums |
4e01753afcac22292caa6d2eb71e7b2fe7cf5e2da9ed760f7f9634790ec2c9c9
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/2.0.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/40.8.0 requests-toolbelt/0.8.0 tqdm/4.36.1 CPython/3.7.4
|
Release files / sqlint-0.2.4-py3-none-any.whl
| Download URL | sqlint-0.2.4-py3-none-any.whl |
|---|---|
| Size | 28.0 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
f0ef21658a2003bfce2dc63354d46c1057e516f2b5f5e0191774b261e8f45fd5
|
|
BLAKE2b-256 checksum How to use checksums |
ee6c482bae9a62c4fd45788b4134e8fdc8f3fdf6a93c245c528df77b69e45bed
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/2.0.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/40.8.0 requests-toolbelt/0.8.0 tqdm/4.36.1 CPython/3.7.4
|