No project description provided
Project description
dynamodb-python
Installation
Requirements
Dependencies
- python = "^3.9"
- ddbcereal
- botocore
- boto3
- requests
Credentials
You will first need to set your AWS credentials. Since this library uses boto3
under the hood, you can use the same methods as described in the boto3 documentation. In short, AWS looks for credentials in these places:
- Environment variables
- Shared credentials file (
~/.aws/credentials
) - AWS config file (
~/.aws/config
)
You cacn also pass a dictionary to DynamoDB
class:
from dynamodb_python import DynamoDB
dynamodb = DynamoDB(credentials={
"aws_access_key_id": ACCESS_KEY,
"aws_secret_access_key": SECRET_KEY,
"aws_session_token": SESSION_TOKEN
})
How to use
Having a table called table_name
, you can access it like this:
from dynamodb_python import DynamoDB
dynamodb = DynamoDB()
table = dynamodb.table_name
And then you can get an item like this:
table.read_item(key={"partition_key": "key", "sort_key": "sort_key" }) # NOTE that sort_key is optional
Or you can get a list of items with the same key like this:
table.read_items(key={"partition_key": "key"}) # NOTE that you can also pass in boto3 condition key
Or you can write an item like this:
table.write(key={"partition_key": "key", "sort_key": "sort_key"}, data={"data": "data"})
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
dynamodb_python-0.1.0.tar.gz
(8.7 kB
view hashes)
Built Distribution
Close
Hashes for dynamodb_python-0.1.0-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | d267e881a3f246d6db3b250ce5f0676b55cda7abda0673f66691029128598021 |
|
MD5 | 5f455eceec3ba28f45b593a6d85a4a56 |
|
BLAKE2b-256 | 2bd430f66c2abeb725a20534ca2d4bc96dd2e00d55ab2efe75dd225229478b4a |