sqllineage
SQL Lineage Analysis Tool powered by Python
What it is and what it does
SQLLineage is a Python tool that analyzes SQL statements to extract data lineage—the flow of data from source tables through transformations to target tables. It abstracts away the complexity of SQL parsing by using pluggable parsers (sqlfluff and sqlparse) and stores lineage information in a graph structure using networkx. The tool works at both table and column levels, identifying which tables are read and written, and tracking individual column transformations across joins, aggregations, and CTEs.
You can use it as a command-line tool to analyze SQL files or inline queries, or import it as a library in Python code. It supports dialect-aware parsing, can optionally integrate with live database metadata via sqlalchemy to resolve wildcards and ambiguous column references, and includes graph visualization of lineage as a DAG. It handles multiple SQL statements in sequence, identifying intermediate tables that serve as both targets and sources.
Use it for:
- Audit data pipelines by tracing which source tables feed into a target table through multiple transformation steps.
- Generate data governance documentation showing column-level lineage for compliance and impact analysis.
- Detect unused intermediate tables or orphaned source tables in a multi-statement ETL script.
- Visualize DAG of table dependencies to understand data flow in complex SQL workflows.
- Resolve column ambiguities in JOIN-heavy queries by connecting to live database metadata.
Worth the install?
AI-flagged interpretation of the facts on this page — verify before relying
SQLLineage parses SQL statements to extract and visualize data lineage—identifying source tables, target tables, and intermediate tables involved in data transformations.
Yes. SQLLineage is actively maintained, has no known vulnerabilities, installs with low friction, and solves a real problem in data governance and pipeline auditing. The MIT license imposes no restrictions. It is suitable for production use in both open-source and commercial contexts.
Install
sqllineage on PyPI
pip
pip install sqllineageuv
uv add sqllineagepoetry
poetry add sqllineageInstalling sqllineage
Before you install
Low friction installation with a pure-Python wheel. The package is actively maintained with a recent release and depends on well-established libraries (sqlparse, sqlfluff, networkx, rustworkx, sqlalchemy). Supports modern Python versions and has been in production use since 2019.
License in practice
MIT license permits unrestricted use, modification, and distribution in both open-source and commercial projects, with only attribution required.
Quickstart
pip install sqllineage
from sqllineage.runner import LineageRunner
runner = LineageRunner("INSERT INTO db1.table1 SELECT * FROM db2.table2")
print(runner.source_tables)
print(runner.target_tables)
Requires Python 3.10 or later.
Verify before relying
- Performance characteristics with very large SQL files or complex multi-statement queries.
- Completeness of dialect support beyond the documented examples.
- Whether metadata-awareness via sqlalchemy connection strings is production-tested across all supported databases.
Package facts
| License | MIT (permissive) |
| Python support | supports the current Python release (>=3.10) |
| Install friction | low — pure-Python wheel |
| Runtime dependencies | 5 — networkx, rustworkx, sqlalchemy, sqlfluff, sqlparse |
| Maintenance | actively maintained — 90 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 1,725,919/month — #3,611 on PyPI (30-day window, as of 2026-08-14) |
| Known vulnerabilities | none known (OSV.dev, checked 2026-08-14) |
Evidence: sqllineage-1.5.8-py3-none-any.whl
Keywords: data-discovery, data-governance, data-lineage, lineage, metadata, sql
Tags
More Database packages
psycopg2-binary is a PostgreSQL database…
copyleft · top 1,000 on PyPI
redisPython client library for connecting to and…
permissive · top 1,000 on PyPI
ydbYDB Python SDK is the official client library…
permissive · top 1,000 on PyPI
snowflake-connector-pythonConnects Python applications to Snowflake data…
permissive · top 1,000 on PyPI
sqlparsesqlparse tokenizes SQL text into a tree of…
permissive · top 1,000 on PyPI
dbt-adaptersProvides base adapter protocols and shared…
permissive · top 1,000 on PyPI
collate-sqllineageAnalyzes SQL statements to extract source and…
permissive · top 5,000 on PyPI
syntaqliteParse, format, validate, and tokenize SQLite…
permissive · top 15,000 on PyPI
openlineage-sqlProvides a Python interface to a Rust-based SQL…
unclear · top 5,000 on PyPI
sql-metadataParses SQL queries using sqlglot and extracts…
permissive · top 5,000 on PyPI
dbt-colibriExtracts column-level lineage from dbt projects…
permissive · top 15,000 on PyPI
sqlglotSQLGlot parses, transpiles, optimizes, and…
permissive · top 1,000 on PyPI
sqlvalidatorFormats, validates, and checks SQL SELECT…
permissive · top 15,000 on PyPI
sqlglotrsA SQL parser, transpiler, and optimizer that…
permissive · top 5,000 on PyPI
sqlfluffSQLFluff is a SQL linter and auto-fixer that…
permissive · top 5,000 on PyPI