# tobymao/sqlglot

> SQLGlot is a Python library for parsing, translating, and optimizing SQL. It reads SQL text written in one dialect and converts it into a dialect-neutral expression tree, which can be rewritten and then turned back into SQL for another dialect. SQLGlot is written purely in Python and is described as having no dependencies.

Source: https://github.com/tobymao/sqlglot
Indexed: commit d375836 on 2026-10-26 by Repowise. Facts come from the source and git history, not from the maintainer.

## Facts

- Type: Command-line tool
- Language: Python
- Stars: 9,798 at index time
- License: MIT
- Code health: 4.2/10, Needs_work
- Last commit: 2026-10-26
- Contributors: 466

## Install

From the README: https://github.com/tobymao/sqlglot#install

Clone the sqlglot repository.
    git clone https://github.com/tobymao/sqlglot.git

Move into the sqlglot folder.
    cd sqlglot

Install the pure Python version from PyPI.
    pip3 install sqlglot

From a local checkout, install the package with make.
    make install

## How it works

SQL text enters through the functions exposed at the package root in sqlglot/__init__.py, and sqlglot/__main__.py is the module entry point. The parser in sqlglot/parser.py builds the dialect-neutral expression tree from the input. An optional optimizer can rewrite that tree into a canonical form. sqlglot/generator.py then produces SQL text from the tree, and dialect modules such as sqlglot/dialects/duckdb.py supply the rules for each target dialect. The same tree is also used by the in-memory executor and the AST diff. pdoc/cli.py builds the HTML API reference.

- pdoc/cli.py: entry point
- sqlglot/__init__.py: entry point
- sqlglot/__main__.py: entry point
- .github/ISSUE_TEMPLATE/bug_report.md: central file
- .github/ISSUE_TEMPLATE/feature_request.md: central file
Modules: sqlglot, tests, benchmarks, .github, root, pdoc, sqlglotc. 275 files, 125,231 lines, 6,434 symbols.

## Code health

- Score: 4.2/10 (Needs_work)
- Rank: #248 of 4,000+ indexed repos
- Hotspots: sqlglot/parser.py, sqlglot/dialects/duckdb.py, sqlglot/generator.py, sqlglot/dialects/dialect.py, sqlglot/generators/duckdb.py
- Lowest file: sqlglot/parser.py
- Dead code: 2 findings

## Maintenance

- Last commit 2026-10-26, first commit 2021-03-13, 8,458 commits
- 466 contributors, bus factor 2

## Security

- Security findings are shown to signed-in users at https://repowise.dev/repo/tobymao/sqlglot/security

## More

- Page: https://repowise.dev/repo/tobymao/sqlglot
- Ask this codebase: https://repowise.dev/repo/tobymao/sqlglot/chat
- Docs: https://repowise.dev/repo/tobymao/sqlglot/docs
- MCP (signs in with Repowise on first use):
    claude mcp add --transport http repowise https://api.repowise.dev/mcp/tobymao/sqlglot
