py-partiql-parser is a pure Python tokenizer, parser, and executor for the PartiQL language. PartiQL is an expressive, SQL-compatible query language for relational, semi-structured, and nested data, primarily maintained by Amazon. The library is currently at version 0.6.3 and appears to be actively maintained, with releases indicating ongoing development, though without a fixed cadence.
pip install py-partiql-parserVerified import paths — ran on the pinned version, not inferred.
This example demonstrates how to parse a PartiQL statement into an Abstract Syntax Tree (AST) and then execute it against an in-memory Python list of dictionaries using the built-in executor.
Refer to the project's GitHub repository for the latest documentation and changelog. Test thoroughly when upgrading.
Consult both the `py-partiql-parser` documentation and AWS's official PartiQL documentation for DynamoDB to understand potential dialect differences if targeting AWS services.
For live AWS DynamoDB queries, use `boto3.client('dynamodb').execute_statement(Statement='...')`. Use `py-partiql-parser` for local PartiQL AST manipulation or in-memory execution.When writing PartiQL for DynamoDB, avoid `AS` aliases in `SELECT` statements. If this parser generates an AST with aliases, consider how that AST will be used downstream, especially if it's meant for AWS services.
Ensure `DynamoDBStatementParser` is instantiated with the `source_data` argument, providing the PartiQL string to be parsed, e.g., `parser = DynamoDBStatementParser(source_data='SELECT * FROM my_table')`.
Install the library using pip: `pip install py-partiql-parser` or ensure the import statement is correct, e.g., `from py_partiql_parser import PartiQLParser`.
Review the PartiQL query for syntax errors, incorrect keywords, or improper structure. Consult the PartiQL specification or examples for correct syntax, especially for complex queries or nested data. For instance, ensure proper quoting for identifiers if they contain special characters or are reserved words.
Enclose the DynamoDB table name (and potentially attribute names) in double quotes within the PartiQL query string. For example, `SELECT * FROM "my-table" WHERE id = '123'` instead of `SELECT * FROM my-table WHERE id = '123'`.
Ensure you are importing and instantiating the correct parser class (e.g., `from py_partiql_parser import PartiQLParser` or `from py_partiql_parser import S3SelectParser` or `from py_partiql_parser import DynamoDBStatementParser`) and calling its `parse` method with the appropriate arguments. Check the library's documentation for the correct class and method signatures for your specific use case.
No dependency data recorded yet.