A simple Google DataStore client
Project description
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'])
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Filename, size | File type | Python version | Upload date | Hashes |
---|---|---|---|---|
Filename, size datastore_client-0.0.7-py3-none-any.whl (3.9 kB) | File type Wheel | Python version py3 | Upload date | Hashes View |
Filename, size datastore_client-0.0.7.tar.gz (3.1 kB) | File type Source | Python version None | Upload date | Hashes View |
Close
Hashes for datastore_client-0.0.7-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | e5c7894c9f923b241344d4f9ba40796c9f4c5e59fe10815020970dfbe2b13ffb |
|
MD5 | 8a7d3c459a613b3bb130ea33e21a60b2 |
|
BLAKE2-256 | fe3cad172c5352fe2dc283b95d0c5c15a1ad663d40328790ff7fe4525b885ecf |