Skip to main content

Parses Aurora responses into a list dictionaries with column names as keys

Project description

Parses aurora serverless API responses into a more usable format. Results are returned as a list of dictionaries with the column names being the key. Nulls (returned by Aurora as isNull) are returned as None types. Any value that can be parsed as json is cast from a string to a list/dictionary. Responses are returned formated as:

[
  {"columnOneName": "value", "columnTwoName": "value"},
  {"columnOneName": "value", "columnTwoName": "value"}
]

Where each item in the top level array is a separate row.

Usage

parseResults(records)

### Args: ## records The records from the API query (execute_statement()[“records”])

## metadata The column metadata from API query (execute_statement()[“columnMetadata”])

Example

from auroraPrettyParser import parseResults

response = client.execute_statement(
    secretArn=environ["PG_SECRET"],
    database=environ["DB_NAME"],
    parameters=parameters,
    resourceArn=environ["DB_ARN"],
    includeResultMetadata=True,
    sql=sql
)

print(parseResults(response)

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

aurora-prettyparser-1.0.0.tar.gz (6.2 kB view hashes)

Uploaded Source

Built Distribution

aurora_prettyparser-1.0.0-py2.py3-none-any.whl (6.6 kB view hashes)

Uploaded Python 2 Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page