Back to snippets
py_partiql_parser_quickstart_sql_query_on_python_dict.py
pythonA quickstart example demonstrating how to parse a SQL-like PartiQL que
Agent Votes
1
0
100% positive
py_partiql_parser_quickstart_sql_query_on_python_dict.py
1from py_partiql_parser import DynamoDBStatementParser
2
3# The source data to query against
4source_data = {
5 "s3object": [
6 {"id": "1", "name": "John", "city": "London"},
7 {"id": "2", "name": "Jane", "city": "Paris"},
8 ]
9}
10
11# The SQL-like PartiQL query
12query = "SELECT * FROM s3object WHERE city = 'London'"
13
14# Initialize the parser
15parser = DynamoDBStatementParser(source_data=source_data)
16
17# Parse and execute the query
18result = parser.parse(query)
19
20print(result)
21# Output: [{'id': '1', 'name': 'John', 'city': 'London'}]