{"repo":"macbre/sql-metadata","free":true,"listed":false,"github":"https://github.com/macbre/sql-metadata","clone":"git clone https://github.com/macbre/sql-metadata.git","description":"Uses tokenized query returned by python-sqlparse and generates query metadata","language":"Python","stars":882,"topics":["sql","parser","database","sql-parser","metadata","sqlparse","python-package","python3-library","hiveql","hive"],"license":"MIT","category":"databases-storage","readme_excerpt":"sql-metadata Uses sqlglot to parse SQL queries and extract metadata. Extracts column names and tables used by the query. Automatically conduct column alias resolution , sub queries aliases resolution as well as tables aliases resolving . Provides also a helper for normalization of SQL queries . Supported queries syntax: MySQL PostgreSQL Sqlite MSSQL Apache Hive (note that listed backends can differ quite substantially but should work in regard of query types supported by sql-metadata ) You can test the capabilities of sql-metadata with an interactive demo: https://sql-app.infocruncher.com/ Usage Extracting raw sql-metadata tokens Extracting columns from query Extracting columns aliases from query Extracting output column names Detecting query type Handling invalid queries Extracting tables from query Extracting values from insert query Extracting limit and offset Extracting with names Extracting sub-queries See tests file for more examples of a bit more complex queries. Queries normalization and comments extraction See test/test normalization.py file for more examples of a bit more complex queries. Migrating from sql metadata 1.x / 2.x The sql metadata.compat module (previously provided for v1 → v2 migration) has been removed in v3 . Port your code to the class-based Parser API shown in the examples above: Old v1 helper v3 replacement ------------------------------- ------------------------------------------- generalize sql(sql) Parser(sql).generalize get query columns(sql) P","default_branch":null,"files":null,"tree":[],"storefront":"/r/macbre","claimed":false,"request_supported":{"post":"https://gitbuyer.com/r/macbre/sql-metadata/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."}