Skip to main content

Simple DataStore Client

A simple Google DataStore client that exposes 3 functions on the DatastoreClient class.

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

from datastore_client.client import DatastoreClient

client = DatastoreClient(namespace='namespace_A')

The following will change the namespace for all subsequent function calls.

from datastore_client.client import DatastoreClient

client = DatastoreClient()
client.client.namespace = 'specific_namespace'

set_key

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

from datastore_client.client import DatastoreClient

client = DatastoreClient()
client.get_key(LOGIN_ENTITY, username)

query_entity

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'])

Metadata

Release files for datastore-client 0.0.10

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for datastore-client 0.0.10
File Size Uploaded
datastore_client-0.0.10.tar.gz 2.7 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for datastore-client 0.0.10
File Interpreter ABI Platform
datastore_client-0.0.10-py3-none-any.whl Python 3 none any Details

Total release size: 6.7 kB

Release files / datastore_client-0.0.10.tar.gz

Download URL datastore_client-0.0.10.tar.gz
Size 2.7 kB
Tags Source
SHA-256 checksum
How to use checksums
e33ebb0fa8011869a60f35c8f8b6c3ae08a7922d0025ab97e81c37a0aeeba291
BLAKE2b-256 checksum
How to use checksums
02532e12df877fa317be42007812569a4cc2e960b8bc62f73778d5c82eee47a4
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.4.2 CPython/3.9.11 Darwin/21.4.0

Release files / datastore_client-0.0.10-py3-none-any.whl

Download URL datastore_client-0.0.10-py3-none-any.whl
Size 4.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
e7edfa701b8b465afcc1832c64adce979cc177c8f66897635975a64019571cc6
BLAKE2b-256 checksum
How to use checksums
c7e6a86ae6ae50c5be1d9694525c3b9a54c9597f49db69e70a34447b2b5491b5
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.4.2 CPython/3.9.11 Darwin/21.4.0

Release history Release notifications | RSS feed

This release

0.0.10 This release

2 release files

0.0.9

2 release files

0.0.8

2 release files

0.0.7

2 release files

0.0.6

2 release files

0.0.5

2 release files

0.0.4

2 release files

0.0.3

2 release files

0.0.2

2 release files

0.0.1

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page