Pure Python PartiQL Parser
Project description
py-partiql-parser
A tokenizer/parser/executor for the PartiQL-language, in Python.
Much beta, such wow. Feel free to raise any issues you encounter.
S3 Usage
import json
from py_partiql_parser import S3SelectParser
original_json = json.dumps({"a1": "b1", "a2": "b2"})
parser = S3SelectParser(source_data={"s3object": original_json})
result = parser.parse("SELECT * FROM s3object")
DynamoDB Usage
import json
from py_partiql_parser import DynamoDBStatementParser
parser = DynamoDBStatementParser(source_data={"table1": {"a1": {"S": "b1"}, "a2": {"S": "b2"}}})
result = parser.parse("SELECT * from table1 WHERE a1 = ?", parameters=[{"S": "b1"}])
Meat
The important logic of this library can be found here: https://github.com/bblommers/py-partiql-parser/blob/main/py_partiql_parser/_internal/parser.py
It is implemented as a naive, dependency-free, TDD-first tokenizer.
Outstanding
- Support for functions such as
count(*)
- Support for CSV conversion. A start has been made in
_internal/csv_converter.py
- .. and I'm sure many other things.
Notes
The first iteration of this library was based on the spec, found here: https://partiql.org/assets/PartiQL-Specification.pdf
AWS doesn't follow its own spec though, most notably:
- a file containing a list (with multiple JSON documents) cannot be queried normally (
select *
returns everything, but you cannotselect key
for each document in the list) select values
is not supported
Security contact information
To report a security vulnerability, please use the Tidelift security contact. Tidelift will coordinate the fix and disclosure.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Hashes for py_partiql_parser-0.5.2-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 9c79b59bbe0cb50daa8090020f2e7f3e5a0e33f7846b48924f19a8f7704f4877 |
|
MD5 | d327d28377c563f7ec26d13a3069bdcb |
|
BLAKE2b-256 | e3787a3f4a2e2c151c85de73f591f7a16d944fe84ee6f5422c2dc3cd3a5baccc |