odooless


Nameodooless JSON
Version 0.2.4 PyPI version JSON
download
home_pagehttps://github.com/Barameg/odooless.git
SummaryA DynamoDB ORM inspired by Odoo
upload_time2023-10-31 18:56:25
maintainer
docs_urlNone
authorSam Hasan
requires_python>=3.6
license
keywords odooless dynamodb orm odoo
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # Odooless

![Build Status](https://github.com/Barameg/odooless/actions/workflows/build.yml/badge.svg)

An Odoo-like serverless ORM for AWS DynamoDB 


## Installation

``` pip install odooless ```

## Getting Started

Define AWS credentials as environment variables 

```python
from odooless import Model, DB

DB._region_name = 'us-west-2' # AWS region
DB._endpoint_url = 'http://localhost:8000' # Omit for AWS cloud DynamoDB
DB._aws_access_key_id = 'test' # AWS access key id
DB._aws_secret_access_key = 'test' # AWS secret access key

```

## Model Definition

To create a new model

``` python
from odooless import models


class Users(models.Model):
    _name = 'Users' # dynamodb table name
    _limit = 80 # define default limit number of records to get from db
    _fields = [
        {
            'name': 'fieldName',
            'type': 'S', # supported field types are Binary as B, Integer as N, String as S 
            'index': True, # create global secondary index for this attribute
        }, ... # attribute definition 
    ]
```

## Methods
Currently available methods
### create
``` python
    from models import Users

    someUser = Users().create({
        'key': 'value',
    }) # create single record

    someUsers = Users().create([
        {
            'key': 'value',
        },
        {
            'key': 'value',
        }, ...
    ]) # or create multiple records
```

### read
``` python
    from models import Users

    someUsers = Users().read(id, fields) # returns recordset 
```

### search
``` python
    from models import Users

    domain = [
        ('field1', '=', 'value0'),
        ('field2', '>=', 'value1'),                                  
        ('field3', '<=', 'value2'),                                  
        ('field4', 'IN', ['value0', 'value1', 'value2',]),
        ('field5', 'between', ['value0', 'value1',]),
        ('field5', 'contains', 'value'),
        ('field5', 'begins_with', 'value'),
        ....
    ] 
    someUsers = users.search(field0=value, domain) # the search method takes index attribute name as a keyword parameter along with a domain that does not include this attribute and returns list of records

    for user in someUsers:
        print(user.name) 
```

### search_read
``` python
    from models import Users

    domain = [
        ('field1', '=', 'value0'),
        ('field2', '>=', 'value1'),
        ('field3', '<=', 'value2'),
        ('field4', 'IN', ['value0', 'value1', 'value2',]),
        ('field5', 'between', ['value0', 'value1']),
        ('field5', 'contains', 'value'),
        ('field5', 'begins_with', 'value'),
        ....
    ] # currently simple query operators soon will add full polish-notation support

    fields = [
        'field1',
        'field2',
        ....
    ]
    someUsers = Users().search_read(field0=value, domain, fields) # the search method takes index attribute name as a keyword parameter along with a domain that does not include this attribute and returns list of records

    for user in someUsers:
        print(user.name) 
```
### write
``` python
    from models import Users

    users.write({
        'id': 'UUIDv4'
        'key': 'value',
    }) # you can update single record by passing its id to model method

    users.write([
        {
            'id': 'UUIDv4'
            'key': 'value',
        },
        {
            'id': 'UUIDv4'
            'key': 'value',
        },...
    ]) # you can update multiple records by passing id of record

    someUser = Users().read(ids)

    for user in someUsers:
        user.write({
            'key': 'value',
        }) # no need to include id if you use update on the instance
```



### delete
``` python
    from models import Users

    someUser = Users().delete(ids) # you can delete single or multiple records
```



            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/Barameg/odooless.git",
    "name": "odooless",
    "maintainer": "",
    "docs_url": null,
    "requires_python": ">=3.6",
    "maintainer_email": "",
    "keywords": "odooless,dynamodb,orm,odoo",
    "author": "Sam Hasan",
    "author_email": "sam@barameg.co",
    "download_url": "https://files.pythonhosted.org/packages/66/12/1460410d43945f017b1193917ef669a4b975ced57a0b882b7012edb5ef84/odooless-0.2.4.tar.gz",
    "platform": null,
    "description": "# Odooless\n\n![Build Status](https://github.com/Barameg/odooless/actions/workflows/build.yml/badge.svg)\n\nAn Odoo-like serverless ORM for AWS DynamoDB \n\n\n## Installation\n\n``` pip install odooless ```\n\n## Getting Started\n\nDefine AWS credentials as environment variables \n\n```python\nfrom odooless import Model, DB\n\nDB._region_name = 'us-west-2' # AWS region\nDB._endpoint_url = 'http://localhost:8000' # Omit for AWS cloud DynamoDB\nDB._aws_access_key_id = 'test' # AWS access key id\nDB._aws_secret_access_key = 'test' # AWS secret access key\n\n```\n\n## Model Definition\n\nTo create a new model\n\n``` python\nfrom odooless import models\n\n\nclass Users(models.Model):\n    _name = 'Users' # dynamodb table name\n    _limit = 80 # define default limit number of records to get from db\n    _fields = [\n        {\n            'name': 'fieldName',\n            'type': 'S', # supported field types are Binary as B, Integer as N, String as S \n            'index': True, # create global secondary index for this attribute\n        }, ... # attribute definition \n    ]\n```\n\n## Methods\nCurrently available methods\n### create\n``` python\n    from models import Users\n\n    someUser = Users().create({\n        'key': 'value',\n    }) # create single record\n\n    someUsers = Users().create([\n        {\n            'key': 'value',\n        },\n        {\n            'key': 'value',\n        }, ...\n    ]) # or create multiple records\n```\n\n### read\n``` python\n    from models import Users\n\n    someUsers = Users().read(id, fields) # returns recordset \n```\n\n### search\n``` python\n    from models import Users\n\n    domain = [\n        ('field1', '=', 'value0'),\n        ('field2', '>=', 'value1'),                                  \n        ('field3', '<=', 'value2'),                                  \n        ('field4', 'IN', ['value0', 'value1', 'value2',]),\n        ('field5', 'between', ['value0', 'value1',]),\n        ('field5', 'contains', 'value'),\n        ('field5', 'begins_with', 'value'),\n        ....\n    ] \n    someUsers = users.search(field0=value, domain) # the search method takes index attribute name as a keyword parameter along with a domain that does not include this attribute and returns list of records\n\n    for user in someUsers:\n        print(user.name) \n```\n\n### search_read\n``` python\n    from models import Users\n\n    domain = [\n        ('field1', '=', 'value0'),\n        ('field2', '>=', 'value1'),\n        ('field3', '<=', 'value2'),\n        ('field4', 'IN', ['value0', 'value1', 'value2',]),\n        ('field5', 'between', ['value0', 'value1']),\n        ('field5', 'contains', 'value'),\n        ('field5', 'begins_with', 'value'),\n        ....\n    ] # currently simple query operators soon will add full polish-notation support\n\n    fields = [\n        'field1',\n        'field2',\n        ....\n    ]\n    someUsers = Users().search_read(field0=value, domain, fields) # the search method takes index attribute name as a keyword parameter along with a domain that does not include this attribute and returns list of records\n\n    for user in someUsers:\n        print(user.name) \n```\n### write\n``` python\n    from models import Users\n\n    users.write({\n        'id': 'UUIDv4'\n        'key': 'value',\n    }) # you can update single record by passing its id to model method\n\n    users.write([\n        {\n            'id': 'UUIDv4'\n            'key': 'value',\n        },\n        {\n            'id': 'UUIDv4'\n            'key': 'value',\n        },...\n    ]) # you can update multiple records by passing id of record\n\n    someUser = Users().read(ids)\n\n    for user in someUsers:\n        user.write({\n            'key': 'value',\n        }) # no need to include id if you use update on the instance\n```\n\n\n\n### delete\n``` python\n    from models import Users\n\n    someUser = Users().delete(ids) # you can delete single or multiple records\n```\n\n\n",
    "bugtrack_url": null,
    "license": "",
    "summary": "A DynamoDB ORM inspired by Odoo",
    "version": "0.2.4",
    "project_urls": {
        "Homepage": "https://github.com/Barameg/odooless.git"
    },
    "split_keywords": [
        "odooless",
        "dynamodb",
        "orm",
        "odoo"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "87dc7868213dc2927de577715a70e8a0a8d26bbc3a4f0be278c1abfab13e748f",
                "md5": "df946b6d1b9833a8b188ffdf7664ef0d",
                "sha256": "3d1c4dd7f2936b79d1b87dc71cc1110873e40a4d0f88c56ac278604c5578575f"
            },
            "downloads": -1,
            "filename": "odooless-0.2.4-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "df946b6d1b9833a8b188ffdf7664ef0d",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.6",
            "size": 6596,
            "upload_time": "2023-10-31T18:56:23",
            "upload_time_iso_8601": "2023-10-31T18:56:23.967195Z",
            "url": "https://files.pythonhosted.org/packages/87/dc/7868213dc2927de577715a70e8a0a8d26bbc3a4f0be278c1abfab13e748f/odooless-0.2.4-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "66121460410d43945f017b1193917ef669a4b975ced57a0b882b7012edb5ef84",
                "md5": "2ad92dbc78962b5d8dd01c8b6df0a597",
                "sha256": "1f3f9a6e72305a1a8d7805d62e1553479f2bde0bb4523e6fc8a2a6a09e12d17f"
            },
            "downloads": -1,
            "filename": "odooless-0.2.4.tar.gz",
            "has_sig": false,
            "md5_digest": "2ad92dbc78962b5d8dd01c8b6df0a597",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.6",
            "size": 7930,
            "upload_time": "2023-10-31T18:56:25",
            "upload_time_iso_8601": "2023-10-31T18:56:25.988901Z",
            "url": "https://files.pythonhosted.org/packages/66/12/1460410d43945f017b1193917ef669a4b975ced57a0b882b7012edb5ef84/odooless-0.2.4.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2023-10-31 18:56:25",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "Barameg",
    "github_project": "odooless",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "lcname": "odooless"
}
        
Elapsed time: 0.41154s