File tree Expand file tree Collapse file tree 1 file changed +33
-0
lines changed
DynamoDB-SDK-Examples/python/WorkingWithPartiQL Expand file tree Collapse file tree 1 file changed +33
-0
lines changed Original file line number Diff line number Diff line change
1
+ import boto3
2
+
3
+ from botocore .exceptions import ClientError
4
+
5
+ # execute statment works with low level client.
6
+ dynamodb = boto3 .client ('dynamodb' , region_name = 'us-east-1' )
7
+ params = {
8
+ 'statement' : 'SELECT * FROM "cerberus-test-3"' ,
9
+ 'next_token' : None
10
+ }
11
+
12
+ # Shows we cannot use inbuilt pagination for execute statement.
13
+ print (dynamodb .can_paginate ('execute_statement' ))
14
+
15
+ while True :
16
+ try :
17
+ if params ['next_token' ] is None :
18
+ response = dynamodb .execute_statement (
19
+ Statement = params ['statement' ])
20
+
21
+ elif params ['next_token' ]:
22
+ response = dynamodb .execute_statement (
23
+ Statement = params ['statement' ], NextToken = params ['next_token' ])
24
+
25
+ # for paginated results response includes nexttoken which can be used for pagination
26
+ if 'NextToken' in response :
27
+ params ['next_token' ] = response ['NextToken' ]
28
+ print ("Next token is updated" )
29
+ else :
30
+ print ("paginated statement executed succesfully" )
31
+ break
32
+ except ClientError as error :
33
+ print (error )
You can’t perform that action at this time.
0 commit comments