{"id":27195,"library":"odata-query","title":"OData Query Parser and Transpiler","description":"A Python library for parsing OData query strings and transpiling them into SQL or other formats. Current version 0.10.0, supports Python 3.7+ (<4.0). Releases are infrequent with minor updates.","status":"active","version":"0.10.0","language":"python","source_language":"en","source_url":"https://github.com/davatron5000/odata-query","tags":["odata","query","parser","sql","transpiler"],"install":[{"cmd":"pip install odata-query","lang":"bash","label":"Latest release"}],"dependencies":[{"reason":"Used for parsing OData grammar","package":"lark-parser","optional":false}],"imports":[{"note":"Case-sensitive: capital O and Q","wrong":"from odata_query import OdataQuery","symbol":"ODataQuery","correct":"from odata_query import ODataQuery"},{"note":"Import the AST module for node types","symbol":"ast","correct":"from odata_query import ast"}],"quickstart":{"code":"from odata_query import ODataQuery\n\n# Parse an OData query string\nquery = ODataQuery(\"$filter=Name eq 'Alice'&$top=10&$orderby=Age desc\")\n\n# Access parsed components\nprint(query.filter)   # Name eq 'Alice'\nprint(query.top)      # 10\nprint(query.orderby)  # Age desc\n\n# Transpile to SQL (experimental)\nfrom odata_query.transpiler import SqlTranspiler\ntranspiler = SqlTranspiler()\nsql = transpiler.transpile(query)\nprint(sql)\n# Output: SELECT * FROM table WHERE Name = 'Alice' ORDER BY Age DESC LIMIT 10","lang":"python","description":"Parse an OData query string and optionally transpile to SQL."},"warnings":[{"fix":"Use SqlTranspiler to get WHERE, ORDER BY, LIMIT clauses, then combine with your own SELECT/FROM.","message":"The library does not build full SQL queries; SqlTranspiler only handles filter, orderby, top, skip. You must provide the SELECT and FROM parts manually.","severity":"gotcha","affected_versions":"<=0.10.0"},{"fix":"To access the parsed AST, use query.filter_ast, query.top_ast, etc. (attributes ending with _ast).","message":"ODataQuery object attributes (filter, top, etc.) are strings, not structured objects. Do not expect them to be parsed into AST nodes by default.","severity":"gotcha","affected_versions":"<=0.10.0"},{"fix":"Check the documentation for the latest transpilation API. Consider contributing to the library if you rely on this.","message":"The 'SqlTranspiler' class is experimental and may change in future versions.","severity":"deprecated","affected_versions":"0.9.0 - 0.10.0"},{"fix":"Sanitize or limit OData query functionality before transpiling. Check the source for supported functions.","message":"Filter expression strings may use OData functions like 'contains', 'startswith', but SqlTranspiler may not support all of them. Unsupported functions cause a NotImplementedError.","severity":"gotcha","affected_versions":"<=0.10.0"}],"env_vars":null,"last_verified":"2026-04-27T00:00:00.000Z","next_check":"2026-07-26T00:00:00.000Z","problems":[{"fix":"Run 'pip install odata-query' in your active environment.","cause":"Library not installed or installed in a different environment.","error":"ModuleNotFoundError: No module named 'odata_query'"},{"fix":"Pass each option separately: ODataQuery(\"$filter=Name eq 'Alice'\") and handle multiple options via the parser's built-in URL handling? Actually ODataQuery class takes a full query string with '&'. This error arises if using invalid OData syntax. Ensure the query is well-formed.","cause":"The OData parser expects individual query options, not URL-encoded string with '&'? May need to split on '&' first.","error":"SyntaxError: Unexpected token '&' in query string"},{"fix":"Use only supported functions (eq, ne, gt, ge, lt, le, and, or, not, substringof, startswith, endswith). For custom functions, extend the transpiler.","cause":"The SqlTranspiler does not support all OData functions.","error":"NotImplementedError: Transpilation of 'contains' not implemented"},{"fix":"Use the .filter attribute or upgrade to >=0.9.0.","cause":"Older versions of the library may not have the '_ast' attributes. Version <0.9?","error":"AttributeError: 'ODataQuery' object has no attribute 'filter_ast'"}],"ecosystem":"pypi","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}