jamestrew / sql-parse

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

sql-parse

Build on top of tree-sitter to allow for semantic searches and perform operations on SQL code found within Python code.

Installation

The release page includes precompiled statically linked binaries for Linux.

Usage

$ sql-parse --help

By default, the tool uses a tree-sitter query to search for the string passed to the first parameter of crs.execute or crs.executemany.

$ sql-parse ts path/to/file.py
$ sql-parse ts path/to/file1.py path/to/file2.py
$ sql-parse ts path/to/directory/

Specify a custom query file with -t

$ sql-parse ts -t path/to/treesitter/query path/to/file.py

Some alternative queries can be found in the queries directory.


Further narrow the down search using regex with the regex subcommand.

$ sql-parse regex 'DECLARE @' path/to/file.py

Paths to search can also be piped in from stdin.

eg: using grep to find all files containing crs.execute

$ grep -rl 'crs\.execute' | sql-parse regex 'DECLARE @'

Find options to subcommands with

$ sql-parse <subcommand> --help

image

About


Languages

Language:Rust 96.2%Language:Python 2.6%Language:Makefile 0.6%Language:Scheme 0.6%