Helper utilities for boto3
Project description
boto3_helpers is a Python library that aims to provide a smoother interface for some of the functions in the AWS boto3 package.
You know how to install it:
pip install boto3-helpers
Have you ever seen anybody make this mistake?
from boto3 import resource as boto3_resource
from boto3.dynamodb.conditions import Key
# Don't do this; you'll miss out if there is more than one page
ddb_table = boto3.resource('dynamodb').Table('example-table')
resp = ddb_table.query(
KeyConditionExpression=Key('username').eq('johndoe')
)
for item in resp.get('Items', []):
print(item)
What they should have done is this:
from boto3 import resource as boto3_resource
from boto3.dynamodb.conditions import Key
# Loop through all the pages
ddb_table = boto3.resource('dynamodb').Table('example-table')
kwargs = {'KeyConditionExpression': Key('username').eq('johndoe')}
while True:
resp = ddb_table.query(**kwargs)
for item in resp.get('Items', []):
print(item)
if 'LastEvaluatedKey' not in resp:
break
kwargs['ExclusiveStartKey'] = resp['LastEvaluatedKey']
With boto3_helpers, you can do the right thing more easily:
from boto3 import resource as boto3_resource
from boto3.dynamodb.conditions import Key
from boto3_helpers.dynamodb import query_table
ddb_table = boto3.resource('dynamodb').Table('example-table')
for item in query_table(
ddb_table, KeyConditionExpression=Key('username').eq('johndoe')
):
print(item)
This package provides helper functions for several similar actions in AWS, such as:
Paging through S3 listings
Updating items in DynamoDB
Assuming roles with STS
Sending and deleting messages with SQS
Pulling metric data from CloudWatch
See the latest docs for more.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file boto3-helpers-2.0.0.tar.gz
.
File metadata
- Download URL: boto3-helpers-2.0.0.tar.gz
- Upload date:
- Size: 26.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.9.7
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | a767a6b2e1192770c2748808eaf754061fe3926ea23f7a039b3276dc56248861 |
|
MD5 | 45ee4a0a8140b08be3a9e9d84cb51c36 |
|
BLAKE2b-256 | e78890ac20aa5d5d088ade883a909e4cb08b9258eb726ec8c381b204c048a265 |
File details
Details for the file boto3_helpers-2.0.0-py3-none-any.whl
.
File metadata
- Download URL: boto3_helpers-2.0.0-py3-none-any.whl
- Upload date:
- Size: 21.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.9.7
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | dc21b0f4007ba0c07e739511e290fe2efac6a79185f627009a58739d131e0545 |
|
MD5 | faa9bb92bcadd8783b9905c8d5ca0301 |
|
BLAKE2b-256 | 9f6a085d58b647f3f2673dfe95644c72b27b98cee6d9b39dd7c7fddffcd6cbed |