Dinamopy
Dinamopy is a python helper library for dynamodb. You can define your access patterns in a json file and can use dynamic method names to make operations.
Installation
Use the package manager pip to install dinamopy.
pip install dinamopy
Usage
app.py
from decimal import Decimal
import dinamopy
class MyHooks(dinamopy.DinamoHooks):
def after_get(self, response):
for k, v in response.items():
if isinstance(v, Decimal):
response[k] = int(v)
return response
db = dinamopy.DinamoPy('dinamopy.json', MyHooks())
db.put(item={
'customerId': 'xyz',
'sk': 'CUST#xyz',
'email': 'rasimandiran@outlook.com',
'fullName': 'Rasim Andiran',
'userPreferences': {'language': 'en', 'sort': 'date', 'sortDirection': 'ascending'}
})
db.overwrite(item={
'customerId': 'xyz',
'sk': 'CUST#xyz',
'email': 'rasimandiran@outlook.com',
'fullName': 'Rasim Andiran',
'userPreferences': {'language': 'en', 'sort': 'date', 'sortDirection': 'ascending'}
})
db.get_customer_profile_by_customer_id(customerId='xyz')
db.get_bookmarks_by_customer_id(customerId='123')
db.get_customer_profile_by_email(email='shirley@example.net')
db.get_bookmarks_by_url(url='https://aws.amazon.com', customerId='123')
db.get_customer_folder(customerId='123', folder='Cloud')
db.update_customer_profile_by_customer_id(customerId='321', sk='CUST#321', new_fields={'email': 'rasimandiran@gmail.com'})
db.update_bookmarks_by_customer_id(customerId='123', sk='https://aws.amazon.com', new_fields={'folder': 'Tools'})
db.update_customer_profile_by_email(email='rasimandiran@gmail.com', new_fields={'fullName': 'Rasim Andiran'})
db.update_bookmarks_by_url(url='https://aws.amazon.com', customerId='123', new_fields={'description': 'Deneme'})
db.update_customer_folder(customerId='123', folder='Cloud', new_fields={'folder': 'CloudFolder'})
db.delete_customer_profile_by_customer_id(customerId='123')
db.delete_bookmarks_by_customer_id(customerId='123', sk='https://aws.amazon.com', new_fields={'folder': 'Tools'})
db.delete_customer_profile_by_email(email='rasimandiran@gmail.com', new_fields={'fullName': 'Rasim Andiran'})
db.delete_bookmarks_by_url(url='https://aws.amazon.com', customerId='123', new_fields={'description': 'Deneme'})
db.delete_customer_folder(customerId='123', folder='Cloud', new_fields={'folder': 'CloudFolder'})
dinamopy.json
{
"region": "localhost",
"port": 8000,
"tableName": "CustomerBookmark",
"partitionKey": "customerId",
"sortKey": "sk",
"timestamps": true,
"paranoid": true,
"returnRawResponse": false,
"logLevel": "debug",
"accessPatterns": {
"customerProfileByCustomerId": {
"table": "table",
"partitionKey": "customerId",
"sortKey": "sk",
"sortKeyOperator": "begins_with",
"sortKeyValue": "CUST#"
},
"bookmarksByCustomerId": {
"table": "table",
"partitionKey": "customerId",
"sortKey": "sk",
"sortKeyOperator": "begins_with",
"sortKeyValue": "http"
},
"customerProfileByEmail": {
"table": "ByEmail",
"partitionKey": "email"
},
"bookmarksByUrl": {
"table": "ByUrl",
"partitionKey": "url",
"sortKey": "customerId"
},
"customerFolder": {
"table": "ByCustomerFolder",
"partitionKey": "customerId",
"sortKey": "folder"
}
}
}
To-Do
- More generic hooks
- Logging
- Tests
- Documentation
Contributing
Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.
License
Metadata
Release files for dinamopy 0.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| dinamopy-0.1.0.tar.gz | 6.5 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| dinamopy-0.1.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 12.5 kB
Release files / dinamopy-0.1.0.tar.gz
| Download URL | dinamopy-0.1.0.tar.gz |
|---|---|
| Size | 6.5 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
34e091098ae25933814b47b6e4224cd138feb2ac6cdd2a69ab93cc606fadc28d
|
|
BLAKE2b-256 checksum How to use checksums |
bb36ca9638b4017e3a6c115c641ab7e40c5b46720093c88e24c0c0ee7d542776
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.8.0 pkginfo/1.8.2 readme-renderer/32.0 requests/2.27.1 requests-toolbelt/0.9.1 urllib3/1.26.8 tqdm/4.62.3 importlib-metadata/4.11.0 keyring/23.5.0 rfc3986/2.0.0 colorama/0.4.4 CPython/3.8.12
|
Release files / dinamopy-0.1.0-py3-none-any.whl
| Download URL | dinamopy-0.1.0-py3-none-any.whl |
|---|---|
| Size | 6.0 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
f624ce983d27ea7bde9f15a4e08b56ede14588ace4ffa79de1528267bc40e666
|
|
BLAKE2b-256 checksum How to use checksums |
1250c14a578a78632da768b024aa9eaa5729f128ce247983d37a8c07e64f7ed7
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.8.0 pkginfo/1.8.2 readme-renderer/32.0 requests/2.27.1 requests-toolbelt/0.9.1 urllib3/1.26.8 tqdm/4.62.3 importlib-metadata/4.11.0 keyring/23.5.0 rfc3986/2.0.0 colorama/0.4.4 CPython/3.8.12
|