$npx skillfedfor your agent

sql-metadata

Uses sqlglot to parse SQL queries and extract metadata

Worth itPyPI DatabaseReleased Jun 20266.8M downloads / moMITPure Python

Decision gist · record as of 2026-08-14

pure-Python wheel — sql_metadata-3.0.1-py3-none-any.whl
v3.0.1 · released 2026-06-30 · Python <4.0,>=3.10 · 1 runtime deps: sqlglot

Yes. Low install friction, active maintenance, MIT license, no known vulnerabilities, and a single well-maintained dependency. Install it if you need to extract or analyze SQL query structure—it handles the parsing complexity so you don't have to.AI-flagged interpretation of the facts on this page — verify before relying

Before you install

  • Low friction: pure Python wheel with a single runtime dependency (sqlglot).
  • Actively maintained with a release 45 days ago and 882 repository stars.

License · maintenance · safety

MIT (permissive) — MIT license permits unrestricted use, modification, and distribution in both open-source and commercial projects.

last release 2026-06-30 (45 days) · last repo commit 2026-08-14 · 882 stars

0 known vulnerabilities (OSV.dev, 2026-08-14) · 6,799,628 downloads/mo, #1,845 on PyPI

Verify before relying

pip install sql-metadata

from sql_metadata import Parser

parser = Parser("SELECT a, b FROM users WHERE id = 1")
print(parser.columns)  # ['a', 'b']
print(parser.tables)   # ['users']
  • Whether performance characteristics are acceptable for large or complex queries
  • Coverage completeness for edge cases across all five supported SQL dialects
Same gist for agents: .md · .json

What it is and what it does

sql-metadata wraps sqlglot to parse SQL queries and extract structural metadata without executing them. It identifies columns, tables, aliases, query types (SELECT, INSERT, UPDATE, DELETE, etc.), and values from INSERT statements. The parser automatically resolves column aliases back to their source columns, table aliases to their actual table names, and subquery aliases to their definitions—useful when you need to understand query dependencies without running the query itself.

The package supports MySQL, PostgreSQL, SQLite, MSSQL, and Apache Hive syntax. It provides both raw token extraction and semantic analysis: you can get columns grouped by their clause (SELECT, WHERE, JOIN, ORDER BY, etc.), output column names preserving aliases, WITH clause definitions, and limit/offset values. It raises InvalidQueryDefinition for structurally invalid SQL, making error handling straightforward.

Use it for

  • Extract column and table dependencies from queries to build data lineage or impact analysis tools
  • Validate query structure and detect referenced tables before execution in data pipelines
  • Resolve aliases and normalize queries for logging, auditing, or query rewriting systems
  • Analyze INSERT statements to map input values to their target columns programmatically
  • Build IDE or documentation tools that need to understand query structure without parsing SQL yourself

Worth the install?

AI-flagged interpretation of the facts on this page. Verify before relying on it.

Worth it

Yes.

Low install friction, active maintenance, MIT license, no known vulnerabilities, and a single well-maintained dependency. Install it if you need to extract or analyze SQL query structure—it handles the parsing complexity so you don't have to.

Install

sql-metadata on PyPI

Before you install

Low friction: pure Python wheel with a single runtime dependency (sqlglot). Actively maintained with a release 45 days ago and 882 repository stars.

License in practice

MIT license permits unrestricted use, modification, and distribution in both open-source and commercial projects.

Quickstart

pip install sql-metadata

from sql_metadata import Parser

parser = Parser("SELECT a, b FROM users WHERE id = 1")
print(parser.columns)  # ['a', 'b']
print(parser.tables)   # ['users']

Verify before relying

  • Whether performance characteristics are acceptable for large or complex queries
  • Coverage completeness for edge cases across all five supported SQL dialects

Package facts

LicenseMIT permissive
Python supportSupports the current Python release <4.0,>=3.10
Install frictionLow. Pure-Python wheel
Runtime dependencies
1 package
sqlglot
MaintenanceActively maintained 45 days since the last release
Last repo commit
First released
Downloads6,799,628 / month, #1,845 on PyPI 30-day window, as of 2026-08-14
Known vulnerabilitiesNone known OSV.dev, checked 2026-08-14
Classifiers
License :: OSI Approved :: MIT LicenseProgramming Language :: Python :: 3Programming Language :: Python :: 3.10Programming Language :: Python :: 3.11Programming Language :: Python :: 3.12Programming Language :: Python :: 3.13Programming Language :: Python :: 3.14

Evidence: sql_metadata-3.0.1-py3-none-any.whl

Tags

Capabilities
sql query parserextract columns from sqlsql metadata extractiontable and column detectionsql query analysisalias resolution sqlsql query introspection
Topics
sql-parsingmetadata-extractionquery-analysis

Let your AI agent find packages like this

Example. Real query, live index.

You found this page by searching. An agent finds it by wishing: SkillFed indexes 14,416 PyPI packages by what they can do, searchable in plain language.

wish › “extract columns from sql”

  • sql-metadataParses SQL queries using sqlglot and extracts metadata: column names,…
  • collate-sqllineageAnalyzes SQL statements to extract source and target tables,…
  • syntaqliteParse, format, validate, and tokenize SQLite SQL using SQLite's own…

Give your agent the search over MCP, or paste the wish link into any chat.

More Database packages

psycopg2-binary Worth it
PyPI · Software Development · released Apr 2026

psycopg2-binary is a PostgreSQL database adapter for Python that implements the DB API 2.0 specification, enabling Python applications to connect to and query PostgreSQL databases with thread-safe concurrent operations.

copyleftcompiled wheel · 3.9+
271.6Mdownloads / mo
redis Worth it
PyPI · Database · released Jul 2026

Python client library for connecting to and executing commands against Redis key-value stores, supporting both synchronous and asynchronous operations.

Install it if your application needs to interact with Redis; the only prerequisite is a running Redis server instance.

MITpure Python · 3.10+
268.3Mdownloads / mo
ydb Worth it
PyPI · Database · released Jul 2026

YDB Python SDK is the official client library for connecting to and querying YDB databases from Python applications.

Install it if you need to connect Python applications to YDB databases.

permissive licensepure Python · 3.10+
210.0Mdownloads / mo
snowflake-connector-python Worth it
PyPI · Software Development · released Aug 2026

Connects Python applications to Snowflake data warehouses using the DB API 2.0 specification, enabling SQL queries, data transfers, and warehouse operations.

Apache-2.0compiled wheel · 3.10+
193.6Mdownloads / mo
sqlparse Worth it
PyPI · Software Development · released Aug 2026

sqlparse tokenizes SQL text into a tree of statements, clauses, and expressions, and provides functions to split scripts, format queries, and inspect parsed tokens without validating dialect or syntax.

Install it if you need to manipulate, format, or analyze SQL text programmatically.

BSD-3-Clausepure Python · 3.10+
148.9Mdownloads / mo
dbt-adapters With conditions
PyPI · Database · released Jul 2026

Provides base adapter protocols and shared functionality that database adapters use to integrate with dbt-core, handling connections, dialect translation, relation caching, and core interface management.

Apache-2.0pure Python · 3.10.0+
121.3Mdownloads / mo

See also sqlglot · sqlglotrs · sqllineage · sqlglotc · acryl-sqlglot · collate-sqllineage · DataProperty · sqlvalidator · python-sql · syntaqlite