sql-metadata
sql-metadata copied to clipboard
Uses tokenized query returned by python-sqlparse and generates query metadata
Example (Postgresql) : https://www.postgresql.org/docs/9.4/queries-values.html ```python >>> from sql_metadata import Parser >>> SQL = "SELECT * FROM (VALUES (1), (2), (3)) AS X(a);" >>> Parser(SQL).tables ["VALUES"] ```
getting error when trying to get the tables for sql below, ``` sql = """ WITH uisd_filter_table as ( select session_id, srch_id, srch_ci, srch_co, srch_los, srch_sort_type, impr_list from uisd where...
SELECT * FROM COMPANY WHERE ID =92 This query's ID value is not returned by your Parser class. Ive tried several other queries with numeric where clause values, None of...
When parsing an sql query then the attribute `parser.columns_dict` returns also information about the join. E.g. see https://github.com/macbre/sql-metadata/blob/master/test/test_getting_columns.py ``` { "select": ["fw1.wiki_id"], "join": ["fw1.wiki_id", "fw2.wiki_id", "fw2.time_id", "dw.wiki_id"], "where": [ "fw1.time_id",...
insert overwrite
In a complex SQL statement with multiple left joins, the field table name in the parsed where value is wrong
Bumps [black](https://github.com/psf/black) from 23.12.1 to 24.2.0. Release notes Sourced from black's releases. 24.2.0 Stable style Fixed a bug where comments where mistakenly removed along with redundant parentheses (#4218) Preview style...
`from sql_metadata import Parser sql_query = """select o_year, sum(case when nation = 'KENYA' then volume else 0 end) / sum(volume) as mkt_share from ( select extract(year from o_orderdate) as o_year,...
## Query ```sql SELECT dj.field_1, cardinality(dj.field_1) as field_1_count, dj.field_2, cardinality(dj.field_2) as field_2_count, dj.field_3 as field_3 FROM dj ``` ## Code ```python parser = Parser(sql_query) print(parser.columns) print(parser.columns_aliases) ``` ## Output ```python...
Parser("SELECT Location FROM cinema WHERE capacity > 300 GROUP BY LOCATION HAVING count(*) > 1").columns >>>['capacity'] Parser('SELECT Location FROM cinema').columns >>>[] guys - shame on u. how can u pass...