DynamoWrapper
DynamoWrapper is a Python library that provides a PyMongo-like interface for Amazon DynamoDB. It simplifies DynamoDB operations, making them more intuitive for developers familiar with MongoDB.
Features
- PyMongo-like API for DynamoDB operations
- Simplified querying with a familiar syntax
- Easy table access and management
- Support for basic CRUD operations
- Index creation and management
- Batch operations support
Installation
You can install DynamoWrapper using pip:
pip install dynamo-wrapper
Quick Start
Here's a simple example to get you started:
from dynamo_wrapper import DynamoClient
# Initialize the client
client = DynamoClient(aws_access_key_id, aws_secret_access_key, region)
# Access a table
table = client['my-table']
# Insert a document
table.insert_one({'id': '1', 'name': 'John Doe', 'age': 30})
# Find documents
results = table.find({'age': ('GT', 25)})
# Update a document
table.update_one({'id': ('EQ', '1')}, {'name': 'Jane Doe'})
# Delete a document
table.delete_one({'id': ('EQ', '1')})
Usage
Initializing the Client
from dynamo_wrapper import DynamoClient
client = DynamoClient(aws_access_key_id, aws_secret_access_key, region)
Accessing a Table
table = client['table-name']
Insert Operations
# Insert one document
table.insert_one({'id': '1', 'name': 'John Doe', 'age': 30})
# Insert multiple documents
table.insert_many([
{'id': '2', 'name': 'Jane Doe', 'age': 28},
{'id': '3', 'name': 'Bob Smith', 'age': 35}
])
Find Operations
# Find one document
result = table.find_one({'id': ('EQ', '1')})
# Find multiple documents
results = table.find({'age': ('GT', 25)})
# Find with projection
results = table.find({'age': ('GT', 25)}, projection=['name', 'age'])
# Find with limit
results = table.find({'age': ('GT', 25)}, limit=10)
Update Operations
# Update one document
table.update_one({'id': ('EQ', '1')}, {'name': 'Jane Doe'})
Delete Operations
# Delete one document
table.delete_one({'id': ('EQ', '1')})
Count Operations
# Count documents
count = table.count({'age': ('GT', 25)})
Index Operations
# Create an index
table.create_index('name')
Query Operators
DynamoWrapper supports the following comparison operators:
EQ: Equal toNE: Not equal toLT: Less thanLTE: Less than or equal toGT: Greater thanGTE: Greater than or equal toIN: In a list of valuesBETWEEN: Between two values
Example:
table.find({'age': ('GT', 25), 'status': ('EQ', 'active')})
Error Handling
DynamoWrapper provides custom exceptions for various error scenarios. Here are some common exceptions:
ItemNotFoundError: Raised when an item is not found in the tableQueryError: Raised when there's an error in query formation or executionUpdateError: Raised when an update operation failsDeleteError: Raised when a delete operation failsInsertError: Raised when an insert operation fails
Example:
from dynamo_wrapper import ItemNotFoundError
try:
result = table.find_one({'id': ('EQ', '999')})
except ItemNotFoundError:
print("Item not found")
Metadata
Release files for dynamo-wrapper 0.1.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| dynamo_wrapper-0.1.1.tar.gz | 7.0 kB | Without provenance | Details for dynamo_wrapper-0.1.1.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| dynamo_wrapper-0.1.1-py3-none-any.whl | Python 3 | none | any | Details for dynamo_wrapper-0.1.1-py3-none-any.whl |
Total release size: 13.2 kB
Release files / dynamo_wrapper-0.1.1.tar.gz
| Download URL | dynamo_wrapper-0.1.1.tar.gz |
|---|---|
| Size | 7.0 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
71102a8b54f6530052ce3c4fed2db938aae226c9a9fc9bb0792d9e26136149a1
|
|
BLAKE2b-256 checksum How to use checksums |
b5e4a7abb9272d58144a19c228dc41aaa2e6a9d74e5ae1027d2b41d68fe46409
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/5.1.1 CPython/3.10.11
|
Release files / dynamo_wrapper-0.1.1-py3-none-any.whl
| Download URL | dynamo_wrapper-0.1.1-py3-none-any.whl |
|---|---|
| Size | 6.2 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
b194e91cd842f82411c8acb68e51bcf9db4b63416dfd1dbc6d074255420c2bae
|
|
BLAKE2b-256 checksum How to use checksums |
96461fab637209e11727591de8c3395afe993904d160f18e2fbb931678686113
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/5.1.1 CPython/3.10.11
|
Security for dynamo-wrapper 0.1.1
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.