Skip to content

Saphall/SQLFluff

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Using SQLFluff to lint and format SQL codes.

image

Examples:

sqlfluff lint --dialect postgres .
sqlfluff fix --dialect tsql src/test.sql

Further: CLI Reference

SQLFluff accepts configuration either through the command line or through configuration files. For file based configuration SQLFluff will look for the following files in order. Later files will (if found) will be used to overwrite any values read from earlier files.

  • setup.cfg
  • tox.ini
  • pep8.ini
  • .sqlfluff
  • pyproject.toml

Installation and Use

1. Install sqlfluff

pip install sqlfluff

2. Add config file like .sqlfluff

3. Test the linting

sqlfluff lint **/*.sql
Example SQL Code:
select id, name from test;

4. Fix the SQL Code

sqlfluff fix **/*.sql
Fixed SQL Code:
SELECT id, name FROM test;

Workflow

On the basis of Rolling out SQLFluff with a new team, added the workflow test.

We check the SQL lint using the workflow file: sql_lint.yml

Refer: PR

Failed CI
Passed CI