Skip to main content

Build Status

Flake8-SQL is a flake8 plugin that looks for SQL queries and checks then against an opinionated style. This style mostly follows SQL Style Guide, but differ in the two following ways. Firstly alignement should be with the INTO rather than INSERT keyword, i.e.

INSERT INTO table (columns)
     VALUES (values)

Secondly JOIN should be aligned to the left of the river, i.e.

SELECT *
  FROM table1
  JOIN table2 ON ...

Warnings

Q440 Keyword is not uppercase

All the SQL reserved keywords should be uppercase.

Q441 Name is not valid

All the non SQL keywords should be snake_case, start with a letter and not end with an _. Due to a limitation snake_case is checks ensure that the word is lowercase.

Q442 Avoid abbreviated keywords

Avoid using abbreviated keywords instead use the full length version.

Q443 Incorrect whitespace around comma

Commas should be followed by whitespace, but not preceded.

Q444 Incorrect whitespace around equals

Equals should be surrounded with whitespace.

Q445 Missing linespace between root keywords

The root keywords SELECT, FROM, INSERT, VALUES, DELETE FROM, WHERE, UPDATE, AND, OR and SET should be on separate lines (unless the entire query is on one line).

Q446 Missing newline after semicolon

Semicolons must be at the end of the line.

Q447 Root keywords should be right aligned

The root keywords SELECT, FROM, INSERT, VALUES, WHERE, UPDATE, AND, OR, JOIN and SET should be right aligned i.e.

SELECT *
  FROM table

Q448 subquery should be aligned to the right of the river

Any subquery should be aligned to the right of the river i.e.

SELECT *
  FROM table
 WHERE column IN
       (SELECT column
          FROM table)

Q449 tokens should be aligned to the right of the river

Any tokens should be aligned to the right of the river i.e

SELECT column1,
       column2
  FROM table

Configuration

At times it is simpler to use a reserved keyword as an identifier than go to the effort to avoid it. To allow for this set the sql-excepted-names option to a comma separated list of these names.

Limitations

String constants are sought out in the code and considered SQL if they contain select from, insert into values, update set or delete from in order. This may and is likely to lead to false positives, in which case simply add # noqa to have this plugin ignore the string.

F-Strings are formatted with the formatted values, {...}, replaced with the constant formatted_value before being linted. This leads to the error message referring to formatted_value rather than what was actually written.

Release files for flake8-SQL 0.4.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for flake8-SQL 0.4.1
File Size Uploaded
flake8-SQL-0.4.1.tar.gz 10.0 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for flake8-SQL 0.4.1
File Interpreter ABI Platform
flake8_SQL-0.4.1-py2.py3-none-any.whl Python 2, Python 3 none any Details

Total release size: 17.9 kB

Release files / flake8-SQL-0.4.1.tar.gz

Download URL flake8-SQL-0.4.1.tar.gz
Size 10.0 kB
Tags Source
SHA-256 checksum
How to use checksums
a8cdd689a5549c6ec73b4478aae152d5e3199270d23a371653f260f7a0e9dedd
BLAKE2b-256 checksum
How to use checksums
807ba82825ecd4aca4e3be4394f31a1179f71bfcdae4d4325c908626d0e09461
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/46.1.3 requests-toolbelt/0.9.1 tqdm/4.44.0 CPython/3.8.2

Release files / flake8_SQL-0.4.1-py2.py3-none-any.whl

Download URL flake8_SQL-0.4.1-py2.py3-none-any.whl
Size 7.9 kB
Tags Python 2 Python 3
SHA-256 checksum
How to use checksums
25cd0485ba5feb5b1abfdd0c5b607e014300bcc3fa2a416a18cf62ecdbaaea96
BLAKE2b-256 checksum
How to use checksums
0ff19bc74ef16d559187526265eae24d971f1bcad825dde760c89fa619104453
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/46.1.3 requests-toolbelt/0.9.1 tqdm/4.44.0 CPython/3.8.2

Release history Release notifications | RSS feed

This release

0.4.1 This release

2 release files

0.4.0

2 release files

0.3.0

2 release files

0.2.0

2 release files

0.1

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page