用于处理appsync响应的工具。
appsync-tools的Python项目详细描述
appsync工具
将aurora和dynamodb响应解析为更可用的格式。在
Aurora结果以字典列表的形式返回,列名称是键。 null(Aurora返回为isNull)作为None类型返回。任何可以解析为json的值都将从字符串转换为列表/字典。 返回的响应格式为:
[{"columnOneName":"value","columnTwoName":"value"},{"columnOneName":"value","columnTwoName":"value"}]
其中顶层数组中的每个项都是一个单独的行。在
Dynamodb结果以字典(用于get_item操作)或字典列表(查询)的形式返回。在
分析极光记录很漂亮
pretty\u parse\u aurora(记录,type\u attribute=None)->列表
参数:
- records——API查询中的记录(execute\u statement()[“records”])
关键字参数:
- type_attribute—如果使用,则在返回之前将结果传递给typeify(results,type_attribute=type_attribute)
正在分析Dynamodb记录
pretty_parse_dynamo(records,type_attribute=None)>;list | dict
参数:
- records——调用query中的项,get_Item
关键字参数:
- type_attribute—如果使用,则在返回之前将结果传递给typeify(results,type_attribute=type_attribute)
fromappsync_toolsimportpretty_parse_dynamoresponse=client.get_item(Key={"pk":"foo","sk":"bar"})print(response.get("Item"))
基于属性向所有记录添加\uyu typename
类型化(记录,type_attribute=“type”)—>;list | dict 参数: records——调用query中的项,get_Item Keyword Args: type_attribute—包含\uuuTypeName值的属性名
示例
fromappsync_toolsimporttypifyresponse=client.get_item(Key={"pk":"foo","sk":"BarType"})print(typify(response.get("Item"),type_attribute="sk"))
- 项目
标签: