Skip to main content

No project description provided

Project description

dynamodb-python

Installation

pip install dynamodb-python

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:

  1. Environment variables
  2. Shared credentials file (~/.aws/credentials)
  3. 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.3.tar.gz (8.3 kB view hashes)

Uploaded Source

Built Distribution

dynamodb_python-0.1.3-py3-none-any.whl (8.7 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page