Skip to content

A cli tool that checks against common SQL anti-patterns

License

Notifications You must be signed in to change notification settings

freshbooks/sqlcop

Repository files navigation

sqlcop

A cli tool to check and guard against anti-patterns

image

image

image

Installation

From PyPI:

pip install sqlcop

Usage

sqlcop is designed to use with nose-sqlcapture.

First, you use nose-sqlcapture to generate a SQL capture file:

nosetests [other options] --with-sqlcapture --sqlcapture-filename=sql.log --sqlcapture-format=json

Run sqlcop on the generated sql log fie:

sqlcop sql.log

For some checks, a database schema is needed. In that case, you need to supply the url to the database so sqlcop can grab the metadata:

sqlcop --db-urls=mysql://user:pwd@host:port/db sql.log

You can specify more than one db_urls at once:

sqlcop --db-urls=mysql://user:pwd@host:port/db1,mysql://user:pwd@host:port/db2 sql.log