{"id":23130,"library":"moz-sql-parser","title":"moz-sql-parser","description":"Moz SQL Parser is a Python library to parse SQL queries and extract the parse tree as a JSON-like structure. Currently at version 4.40.21126, it is actively maintained and does not have a fixed release cadence.","status":"active","version":"4.40.21126","language":"python","source_language":"en","source_url":"https://github.com/klahnakoski/moz-sql-parser","tags":["sql","parser","ast","sql-parser"],"install":[{"cmd":"pip install moz-sql-parser","lang":"bash","label":"PyPI install"}],"dependencies":[],"imports":[{"note":"parse_sql is the old name, still works but parse is preferred.","wrong":"from moz_sql_parser import parse_sql","symbol":"parse","correct":"from moz_sql_parser import parse"},{"note":"","wrong":"","symbol":"format","correct":"from moz_sql_parser import format"}],"quickstart":{"code":"from moz_sql_parser import parse\nsql = \"SELECT a, b FROM table WHERE c > 1\"\nresult = parse(sql)\nprint(result)","lang":"python","description":"Parse a simple SQL query and print the AST."},"warnings":[{"fix":"Print or debug the output to understand the AST shape.","message":"The parsed output is a nested dictionary with keys like 'select', 'from', 'where', etc. The structure may differ from expectations for complex SQL (e.g., JOINs, subqueries). Always inspect the output.","severity":"gotcha","affected_versions":"all"},{"fix":"Use 'from moz_sql_parser import parse' instead of 'parse_sql'.","message":"The function 'parse_sql' has been renamed to 'parse'. 'parse_sql' still works but may be removed in future versions.","severity":"deprecated","affected_versions":">=4.0.0"}],"env_vars":null,"last_verified":"2026-05-01T00:00:00.000Z","next_check":"2026-07-30T00:00:00.000Z","problems":[{"fix":"Simplify the SQL or check the parser's supported syntax. The parser does not understand all SQL dialects.","cause":"The SQL string contains syntax not supported by moz-sql-parser (e.g., certain dialect-specific syntax like MS SQL Server brackets).","error":"ParseException: Expected {SelectStatement}"},{"fix":"Upgrade moz-sql-parser: pip install --upgrade moz-sql-parser. Use correct import: from moz_sql_parser import parse","cause":"Installed an older version (<4.0.0) or imported incorrectly.","error":"AttributeError: module 'moz_sql_parser' has no attribute 'parse'"}],"ecosystem":"pypi","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}