Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/rasimandiran/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.
https://github.com/rasimandiran/dinamopy
aws aws-dynamodb nosql python3
Last synced: 3 days ago
JSON representation
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.
- Host: GitHub
- URL: https://github.com/rasimandiran/dinamopy
- Owner: rasimandiran
- License: mit
- Created: 2022-02-13T18:31:19.000Z (almost 3 years ago)
- Default Branch: main
- Last Pushed: 2022-02-15T18:09:47.000Z (almost 3 years ago)
- Last Synced: 2024-12-19T08:02:53.589Z (7 days ago)
- Topics: aws, aws-dynamodb, nosql, python3
- Language: Python
- Homepage: https://pypi.org/project/dinamopy/
- Size: 10.7 KB
- Stars: 2
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Dinamopy
Dinamopy is a python helper library for [dynamodb](https://aws.amazon.com/dynamodb/). You can define your [access patterns](https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/bp-modeling-nosql-B.html) in a json file and can use dynamic method names to make operations.
## Installation
Use the package manager [pip](https://pip.pypa.io/en/stable/) to install dinamopy.
```bash
pip install dinamopy
```## Usage
### app.py
```python
from decimal import Decimal
import dinamopyclass MyHooks(dinamopy.DinamoHooks):
def after_get(self, response):
for k, v in response.items():
if isinstance(v, Decimal):
response[k] = int(v)
return responsedb = dinamopy.DinamoPy('dinamopy.json', MyHooks())
db.put(item={
'customerId': 'xyz',
'sk': 'CUST#xyz',
'email': '[email protected]',
'fullName': 'Rasim Andiran',
'userPreferences': {'language': 'en', 'sort': 'date', 'sortDirection': 'ascending'}
})db.overwrite(item={
'customerId': 'xyz',
'sk': 'CUST#xyz',
'email': '[email protected]',
'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='[email protected]')
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': '[email protected]'})
db.update_bookmarks_by_customer_id(customerId='123', sk='https://aws.amazon.com', new_fields={'folder': 'Tools'})
db.update_customer_profile_by_email(email='[email protected]', 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='[email protected]', 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
```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
[MIT](https://choosealicense.com/licenses/mit/)