{"repo":"andialbrecht/sqlparse","free":true,"listed":false,"github":"https://github.com/andialbrecht/sqlparse","clone":"git clone https://github.com/andialbrecht/sqlparse.git","description":"A non-validating SQL parser module for Python","language":"Python","stars":4014,"topics":["formatter","python","sql","sql-formatter","sql-parser","tokenizer"],"license":"BSD-3-Clause","category":"databases-storage","readme_excerpt":"sqlparse A non-validating SQL parser for Python. Split scripts into statements, format them, and walk their token tree. sqlparse tokenizes SQL text and groups the parts it recognizes into a tree of statements, clauses, identifiers and expressions. It accepts any input without validating it, and makes no assumptions about a particular SQL dialect, so vendor extensions and templated SQL parse too. It is a building block for formatters, linters, editors and query analysis tools. Licensed under the New BSD license. Install Usage Three module-level functions cover most needs: split() , format() and parse() . Split a script into statements Format a statement format() accepts the same options as the command line, among them reindent , keyword case , strip comments and indent width . Parse and inspect a statement Tokens with a ttype are leaves. The others are groups you can descend into, which is how nested constructs like subqueries and CASE expressions are represented. See Analyzing SQL statements for the traversal API. Command line Installing sqlparse also provides the sqlformat command. It reads from stdin when the filename is - , writes to stdout by default, and rewrites files in place with --in-place : Run sqlformat --help for all formatting options. Pre-commit hook Format SQL files on commit with pre-commit: The hook defaults to --in-place --reindent . When overriding args , keep --in-place , or the hook writes to stdout and leaves your files unchanged. Links --- --- Documenta","default_branch":null,"files":null,"tree":[],"storefront":"/r/andialbrecht","claimed":false,"request_supported":{"post":"https://gitbuyer.com/r/andialbrecht/sqlparse/request-supported","requests":0},"note":"indexed from public GitHub; nothing is for sale on this page. Clone it from GitHub. Paid listings live at /search."}