Last active
August 20, 2018 11:44
-
-
Save frankyaorenjie/b3a4d2194c4484b7fd17cde47cda6d5d to your computer and use it in GitHub Desktop.
[python3 boto for dynamodb] #aws #dynamodb #python
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
response = dynamodb.batch_get_item( | |
RequestItems={ | |
'visearch_production_meta': { | |
'Keys': batch_i_tx_j_list, | |
'ProjectionExpression': 'm,nd,nk' | |
} | |
} | |
) | |
dynamodb_results.extend(response['Responses']['visearch_production_meta']) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
alias ipy="python -c 'import IPython; IPython.terminal.ipapp.launch_new_instance()'" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
response = dynamodb.query( | |
TableName='visearch_production_image', | |
IndexName='app_id_hash-im_id-index', | |
KeyConditionExpression='a_h = :a_h', | |
ExpressionAttributeValues={':a_h': {'S': a_h}}, | |
ProjectionExpression='i,tx_j' | |
) | |
i_tx_j_list.extend(response['Items']) | |
count += response['Count'] | |
while 'LastEvaluatedKey' in response: | |
response = dynamodb.query( | |
TableName='visearch_production_image', | |
IndexName='app_id_hash-im_id-index', | |
KeyConditionExpression='a_h = :a_h', | |
ExpressionAttributeValues={':a_h': {'S': a_h}}, | |
ProjectionExpression='i,tx_j', | |
ExclusiveStartKey=response['LastEvaluatedKey'] | |
) | |
i_tx_j_list.extend(response['Items']) | |
count += response['Count'] | |
return i_tx_j_list, count |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment