[英]DynamoDB GSIs query doesn't find GSI3 & GSI4 despite they exist
I am working with DynamoDB and testing queries with boto3 and VS Code at the moment.我目前正在使用 DynamoDB 并使用 boto3 和 VS Code 测试查询。 First i only had 2 GSIs and the queries worked fine.
首先,我只有 2 个 GSI,查询工作正常。 Now i created a third and a fourth one.
现在我创建了第三个和第四个。
When trying to query GSI3 and GSI4 i get the following error:尝试查询 GSI3 和 GSI4 时出现以下错误:
ClientError: An error occurred (ValidationException) when calling the ExecuteStatement operation: The table does not have the specified index
Here is my query code for GSI3:这是我的 GSI3 查询代码:
import boto3
import pprint as pp
# dynamodb client
dynamodb_client = boto3.client('dynamodb')
# Table Name
table_name_4 = "test_db.GSI3"
# get item
telefon = '4A4EBBF4044C8938AC4E3FF11C7D1D16'
stmt = f"SELECT * FROM {table_name_4} WHERE telefon=?"
pmt =[{ "S": telefon }]
resp = dynamodb_client.execute_statement( Statement=stmt , Parameters=pmt )
pp.pprint(resp['Items'])
Here is my query code for GSI2 that works fine:这是我的 GSI2 查询代码,运行良好:
import boto3
import pprint as pp
# dynamodb client
dynamodb_client = boto3.client('dynamodb')
# Table Name
table_name_3 = "test_db.GSI2"
# get item
personal_accept = 'FALSCH'
stmt = f"SELECT * FROM {table_name_3} WHERE personal_accept=?"
pmt =[{ "S": personal_accept }]
resp = dynamodb_client.execute_statement( Statement=stmt , Parameters= pmt )
#pp.pprint(resp['Items'])
pp.pprint(resp['Items'][0]["titel"])
pp.pprint(resp['Items'][0]["sk"])
pp.pprint(resp['Items'][0]["date"])
All GSIs are active所有 GSI 都处于活动状态
Anybody has an idea what is going wrong?任何人都知道出了什么问题?
Your syntax is wrong for specifying an index for PartiQL, it should be as follows:为 PartiQL 指定索引的语法错误,应该如下所示:
"Table"."Index"
, or in your case "test_db"."GSI3"
etc.... "Table"."Index"
,或在您的情况下"test_db"."GSI3"
等....
https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/ql-reference.select.html#ql-reference.select.parameters https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/ql-reference.select.html#ql-reference.select.parameters
SELECT *
FROM "TableName"."IndexName"
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.