簡體   English   中英

Boto3 DynamoDB - 掃描表參數驗證失敗

[英]Boto3 DynamoDB - Scan Table Parameter validation failed

您好我正在嘗試使用 Boto3 從 DynamoDB 表中讀取數據。 我正在嘗試運行下面的代碼,但出現以下錯誤:

Unknown parameter in input: "KeyConditionExpression", must be one of: TableName, IndexName, AttributesToGet, Limit, Select, ScanFilter, ConditionalOperator, ExclusiveStartKey, ReturnConsumedCapacity, TotalSegments, Segment, ProjectionExpression, FilterExpression, ExpressionAttributeNames, ExpressionAttributeValues, ConsistentRead

我正在嘗試運行的 Python 代碼:

client = boto3.client('dynamodb', region_name='eu-west-1')

customers_table = '-customers'

def dump_table(table_name):
    results = []
    last_evaluated_key = None
    while True:
        if last_evaluated_key:
            response = client.scan(
                TableName=table_name,
                KeyConditionExpression="sort = :sort_key and deletedDate < :firstIngestionDate",
                ExpressionAttributeValues={":sort_key": {"S": "DELETION_EVENT"},
                                           ":firstIngestionDate": {"S": "2021-01-27T23:26:58.280Z"}},
                ExclusiveStartKey=last_evaluated_key
            )
        else:
            response = client.scan(TableName=table_name,
                                   KeyConditionExpression='sort = :sort_key and deletedDate < :firstIngestionDate',
                                   ExpressionAttributeValues={":sort_key": {"S": "DELETION"},
                                                              ":firstIngestionDate": {"S": "2021-01-27T23:26:58.280Z"}})
        last_evaluated_key = response.get('LastEvaluatedKey')
        results.extend(response['Items'])
        if not last_evaluated_key:
            break
    return results


data = dump_table(customers_table)

我最終將“KeyConditionExpression”替換為“FilterExpression”,這似乎成功了。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM