# Simple DataStore Client
A simple Google DataStore client that exposes 3 functions on the `DatastoreClient` class.
```python
class DatastoreClient:
def __init__(self, namespace: str=None, **kwargs) -> None:
self.client = Client(namespace=namespace, **kwargs)
def set_key(
self,
entity_name: str,
key_name: str,
**properties: Any,
) -> None:
...
def get_key(
self,
entity_name: str,
key_name: str,
) -> Optional[Entity]:
...
def query_entity(
self,
entity_name: str,
*query_filters: Tuple[str, str, Any],
projection: List[str]=None,
limit: Optional[int]=None,
) -> Iterator:
...
```
## Examples
### Changing the `namespace`
You can set the `namespace` for the client by passing it in to the constructor
```python
from datastore_client.client import DatastoreClient
client = DatastoreClient(namespace='namespace_A')
```
The following will change the namespace for all subsequent function calls.
```python
from datastore_client.client import DatastoreClient
client = DatastoreClient()
client.client.namespace = 'specific_namespace'
```
### `set_key`
```python
from datastore_client.client import DatastoreClient
client = DatastoreClient()
client.set_key(
entity_name=RECHARGE_NOTES_ENTITY,
key_name=note_key,
username=username,
reference=reference,
note=notes,
)
# This can also be used in batch mode
with client.batch_update():
client.set_key(...)
client.set_key(...)
# Both key updates will be done when the with block exits
```
### `get_key`
```python
from datastore_client.client import DatastoreClient
client = DatastoreClient()
client.get_key(LOGIN_ENTITY, username)
```
### `query_entity`
```python
from datastore_client.client import DatastoreClient
client = DatastoreClient()
product_list = list(client.query_entity(
PRODUCT_ENTITY,
('network', '=', network_name),
('product_type', '=', product_code),
('bundle_size', '=', denomination),
projection=['id'],
limit=1,
))
print(product_list[0]['id'])
```
Raw data
{
"_id": null,
"home_page": "https://github.com/Flickswitch/datastore-client",
"name": "datastore-client",
"maintainer": "",
"docs_url": null,
"requires_python": ">=3.6,<4.0",
"maintainer_email": "",
"keywords": "",
"author": "Jethro Muller",
"author_email": "git@jethromuller.co.za",
"download_url": "https://files.pythonhosted.org/packages/02/53/2e12df877fa317be42007812569a4cc2e960b8bc62f73778d5c82eee47a4/datastore_client-0.0.10.tar.gz",
"platform": null,
"description": "# Simple DataStore Client\n\nA simple Google DataStore client that exposes 3 functions on the `DatastoreClient` class.\n\n```python\nclass DatastoreClient:\n def __init__(self, namespace: str=None, **kwargs) -> None:\n self.client = Client(namespace=namespace, **kwargs)\n\n def set_key(\n self,\n entity_name: str,\n key_name: str,\n **properties: Any,\n ) -> None:\n ...\n\n def get_key(\n self,\n entity_name: str,\n key_name: str,\n ) -> Optional[Entity]:\n ...\n\n def query_entity(\n self,\n entity_name: str,\n *query_filters: Tuple[str, str, Any],\n projection: List[str]=None,\n limit: Optional[int]=None,\n ) -> Iterator:\n ...\n```\n\n## Examples\n\n### Changing the `namespace`\nYou can set the `namespace` for the client by passing it in to the constructor\n```python\nfrom datastore_client.client import DatastoreClient\n\nclient = DatastoreClient(namespace='namespace_A')\n```\n\nThe following will change the namespace for all subsequent function calls.\n\n```python\nfrom datastore_client.client import DatastoreClient\n\nclient = DatastoreClient()\nclient.client.namespace = 'specific_namespace'\n```\n\n### `set_key`\n\n```python\nfrom datastore_client.client import DatastoreClient\n\nclient = DatastoreClient()\nclient.set_key(\n entity_name=RECHARGE_NOTES_ENTITY, \n key_name=note_key, \n username=username, \n reference=reference, \n note=notes,\n)\n\n# This can also be used in batch mode\nwith client.batch_update():\n client.set_key(...)\n client.set_key(...)\n\n# Both key updates will be done when the with block exits\n```\n\n### `get_key`\n\n```python\nfrom datastore_client.client import DatastoreClient\n\nclient = DatastoreClient()\nclient.get_key(LOGIN_ENTITY, username)\n```\n\n### `query_entity`\n\n```python\nfrom datastore_client.client import DatastoreClient\n\nclient = DatastoreClient()\nproduct_list = list(client.query_entity(\n PRODUCT_ENTITY,\n ('network', '=', network_name),\n ('product_type', '=', product_code),\n ('bundle_size', '=', denomination),\n projection=['id'],\n limit=1,\n))\n\nprint(product_list[0]['id'])\n```\n",
"bugtrack_url": null,
"license": "",
"summary": "A simple Google DataStore client",
"version": "0.0.10",
"project_urls": {
"Homepage": "https://github.com/Flickswitch/datastore-client",
"Repository": "https://github.com/Flickswitch/datastore-client"
},
"split_keywords": [],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "c7e6a86ae6ae50c5be1d9694525c3b9a54c9597f49db69e70a34447b2b5491b5",
"md5": "53464f23e275fb81545b0bc237a037e5",
"sha256": "e7edfa701b8b465afcc1832c64adce979cc177c8f66897635975a64019571cc6"
},
"downloads": -1,
"filename": "datastore_client-0.0.10-py3-none-any.whl",
"has_sig": false,
"md5_digest": "53464f23e275fb81545b0bc237a037e5",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.6,<4.0",
"size": 3962,
"upload_time": "2023-05-17T12:45:16",
"upload_time_iso_8601": "2023-05-17T12:45:16.016653Z",
"url": "https://files.pythonhosted.org/packages/c7/e6/a86ae6ae50c5be1d9694525c3b9a54c9597f49db69e70a34447b2b5491b5/datastore_client-0.0.10-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "02532e12df877fa317be42007812569a4cc2e960b8bc62f73778d5c82eee47a4",
"md5": "3f09de169e1cbf2149f460e9eb24c98d",
"sha256": "e33ebb0fa8011869a60f35c8f8b6c3ae08a7922d0025ab97e81c37a0aeeba291"
},
"downloads": -1,
"filename": "datastore_client-0.0.10.tar.gz",
"has_sig": false,
"md5_digest": "3f09de169e1cbf2149f460e9eb24c98d",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.6,<4.0",
"size": 2741,
"upload_time": "2023-05-17T12:45:18",
"upload_time_iso_8601": "2023-05-17T12:45:18.191084Z",
"url": "https://files.pythonhosted.org/packages/02/53/2e12df877fa317be42007812569a4cc2e960b8bc62f73778d5c82eee47a4/datastore_client-0.0.10.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2023-05-17 12:45:18",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "Flickswitch",
"github_project": "datastore-client",
"travis_ci": false,
"coveralls": false,
"github_actions": false,
"lcname": "datastore-client"
}