dynamore-0.1.1
توضیحات
Dynamore is extremely simple Python library for managing entities on DynamoDb.
| ویژگی | مقدار |
|---|---|
| سیستم عامل | - |
| نام فایل | dynamore-0.1.1 |
| نام | dynamore |
| نسخه کتابخانه | 0.1.1 |
| نگهدارنده | [] |
| ایمیل نگهدارنده | [] |
| نویسنده | Ville Kärkkäinen |
| ایمیل نویسنده | ville.karkkainen@outlook.com |
| آدرس صفحه اصلی | https://github.com/villekr/dynamore |
| آدرس اینترنتی | https://pypi.org/project/dynamore/ |
| مجوز | MIT |
DYNAMORE
--------
Dynamore is extremely simple Python library for **managing entities** on DynamoDb. It's designed to be used together with REST API and only supports **single table design**.
Installation
------------
Install from Pypi:
.. code-block:: bash
$ pip install dynamore
Quick start
-----------
Dynamore doesn't manage your tables so create DynamoDb table beforehand e.g. provisioning by CloudFormation.
Here's the simple example on how to create Person schema and store it to DynamoDb:
.. code-block:: Python
from dynamore.dynamodb_proxy import DynamoDbProxy
from dynamore.entity import Entity
class Person(Entity):
SCHEMA = {
"title": "PERSON",
"type": "object",
"required": ["name", "age", "gender", "id_number"],
"properties": {
"name": {"type": "string"},
"age": {"type": "integer", "min": 0, "max": 123},
"gender": {"type": "string", "enum": ["male", "female"]},
"id_number": {"type": "string"},
},
"additionalProperties": False,
}
ID_ATTRIBUTE = "id_number"
db = DynamoDbProxy(table_name="MyTable")
data = {
"name": "Jeanne",
"age": 123,
"gender": "female",
"id_number": "123456"
}
_ = db.post(entity_class=Person, data=data)
# Get single item
item = db.get(
entity_class=Person, data={"id_number": data["id_number"]}
)
# Get all items of type "Person"
items = dynamodb_proxy.get(entity_class=Person)
First a new entity class Person defined. It's **schema** is defined using jsonschema and **id attribute** defines the name of the attribute that is used for uniqueness.
Dynamore stores data to DynamoDb in the following format:
+--------+--------+--------+-----+--------+
| PK | SK | name | age | gender |
+========+========+========+=====+========+
| PERSON | 123456 | Jeanne | 123 | female |
+--------+--------+--------+-----+--------+
By default entity uses partition key "PK" and sort key "SK" value but you can define them otherwise by overriding pr_keys-method.
نیازمندی
| مقدار | نام |
|---|---|
| ==1.12.32 | boto3 |
| >=3.2.0,<4.0.0 | jsonschema |
| >=0.14.0,<0.15.0 | python-dotenv |
زبان مورد نیاز
| مقدار | نام |
|---|---|
| >=3.8,<4.0 | Python |
نحوه نصب
نصب پکیج whl dynamore-0.1.1:
pip install dynamore-0.1.1.whl
نصب پکیج tar.gz dynamore-0.1.1:
pip install dynamore-0.1.1.tar.gz