Skip to main content

An extensible linter for SQL

Project description

build status Documentation Status PyPI version

Catch unsafe SQL migrations.

$ squabble sql/migration.sql
sql/migration.sql:4:46 ERROR: column "uh_oh" has a disallowed constraint [1004]
ALTER TABLE big_table ADD COLUMN uh_oh integer DEFAULT 0;
# Use --explain to get more information on a lint violation
$ squabble --explain 1004
     When adding a column to an existing table, certain constraints can have
     unintentional side effects, like locking the table or introducing
     performance issues.

Squabble works to help automate the process of reviewing SQL migrations by catching simple mistakes, such as:

  • Changing the type of an existing column
  • Adding a new column with a default value or NOT NULL constraint
  • Building an index without using CONCURRENTLY

For more information on why these particular cases can be dangerous:

Currently, most of the rules have been focused on Postgres and its quirks. However, squabble can parse any ANSI SQL and new rules that are specific to other databases are appreciated!


$ pip3 install squabble
$ squabble --help


Squabble is only supported on Python 3.5+

If you’d like to install from source:

$ git clone && cd squabble
$ python3 -m venv ve && source ve/bin/activate
$ python install
$ squabble --help


To see a list of rules, try

$ squabble --list-rules

Then, to show more verbose information about a rule (such as rationale and configuration options)

$ squabble --show-rule AddColumnsDisallowConstraints

Once a configuration file is in place, it can be passed explicitly on the command line, or automatically looked up.

$ squabble -c path/to/config ...

If not explicitly given on the command line, squabble will look for a file named .squabblerc in the following places (in order):

  • ./.squabblerc
  • (git_repo_root)/.squabblerc
  • ~/.squabblerc

Example Configuration

  "reporter": "color",

  "plugins": [

  "rules": {
    "AddColumnsDisallowConstraints": {
      "disallowed": ["DEFAULT", "FOREIGN", "NOT NULL"]


This project would not be possible without:

  • libpg_query - Postgres query parser
  • pglast - Python bindings to libpg_query
  • Postgres - …obviously

Project details

Download files

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

Files for squabble, version 1.0.0rc3
Filename, size File type Python version Upload date Hashes
Filename, size squabble-1.0.0rc3.tar.gz (13.4 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