pygridgain.api package

Submodules

pygridgain.api.affinity module

pygridgain.api.affinity.cache_get_node_partitions(conn: Connection, caches: Union[int, Iterable[int]], query_id: int = None) → pygridgain.api.result.APIResult

Gets partition mapping for a GridGain cache or a number of caches. See “IEP-23: Best Effort Affinity for thin clients”.

Parameters:
  • conn – connection to GridGain server,
  • caches – cache ID(s) the mapping is provided for,
  • query_id – (optional) a value generated by client and returned as-is in response.query_id. When the parameter is omitted, a random value is generated,
Returns:

API result data object.

pygridgain.api.binary module

pygridgain.api.binary.get_binary_type(connection: Connection, binary_type: Union[str, int], query_id=None) → pygridgain.api.result.APIResult

Gets the binary type information by type ID.

Parameters:
  • connection – connection to GridGain server,
  • binary_type – binary type name or ID,
  • query_id – (optional) a value generated by client and returned as-is in response.query_id. When the parameter is omitted, a random value is generated,
Returns:

API result data object.

pygridgain.api.binary.put_binary_type(connection: Connection, type_name: str, affinity_key_field: str = None, is_enum=False, schema: dict = None, query_id=None) → pygridgain.api.result.APIResult

Registers binary type information in cluster.

Parameters:
  • connection – connection to GridGain server,
  • type_name – name of the data type being registered,
  • affinity_key_field – (optional) name of the affinity key field,
  • is_enum – (optional) register enum if True, binary object otherwise. Defaults to False,
  • schema – (optional) when register enum, pass a dict of enumerated parameter names as keys and an integers as values. When register binary type, pass a dict of field names: field types. Binary type with no fields is OK,
  • query_id – (optional) a value generated by client and returned as-is in response.query_id. When the parameter is omitted, a random value is generated,
Returns:

API result data object.

pygridgain.api.cache_config module

Set of functions to manipulate caches.

GridGain cache can be viewed as a named entity designed to store key-value pairs. Each cache is split transparently between different GridGain partitions.

The choice of cache term is due to historical reasons. (GridGain initially had only non-persistent storage tier.)

pygridgain.api.cache_config.cache_create(connection: Connection, name: str, query_id=None) → APIResult

Creates a cache with a given name. Returns error if a cache with specified name already exists.

Parameters:
  • connection – connection to GridGain server,
  • name – cache name,
  • query_id – (optional) a value generated by client and returned as-is in response.query_id. When the parameter is omitted, a random value is generated,
Returns:

API result data object. Contains zero status if a cache is created successfully, non-zero status and an error description otherwise.

pygridgain.api.cache_config.cache_create_with_config(connection: Connection, cache_props: dict, query_id=None) → APIResult

Creates cache with provided configuration. An error is returned if the name is already in use.

Parameters:
  • connection – connection to GridGain server,
  • cache_props – cache configuration properties to create cache with in form of dictionary {property code: python value}. You must supply at least name (PROP_NAME),
  • query_id – (optional) a value generated by client and returned as-is in response.query_id. When the parameter is omitted, a random value is generated,
Returns:

API result data object. Contains zero status if cache was created, non-zero status and an error description otherwise.

pygridgain.api.cache_config.cache_destroy(connection: Connection, cache: Union[str, int], query_id=None) → APIResult

Destroys cache with a given name.

Parameters:
  • connection – connection to GridGain server,
  • cache – name or ID of the cache,
  • query_id – (optional) a value generated by client and returned as-is in response.query_id. When the parameter is omitted, a random value is generated,
Returns:

API result data object.

pygridgain.api.cache_config.cache_get_configuration(connection: Connection, cache: Union[str, int], flags: int = 0, query_id=None) → APIResult

Gets configuration for the given cache.

Parameters:
  • connection – connection to GridGain server,
  • cache – name or ID of the cache,
  • flags – GridGain documentation is unclear on this subject,
  • query_id – (optional) a value generated by client and returned as-is in response.query_id. When the parameter is omitted, a random value is generated,
Returns:

API result data object. Result value is OrderedDict with the cache configuration parameters.

pygridgain.api.cache_config.cache_get_names(connection: Connection, query_id=None) → APIResult

Gets existing cache names.

Parameters:
  • connection – connection to GridGain server,
  • query_id – (optional) a value generated by client and returned as-is in response.query_id. When the parameter is omitted, a random value is generated,
Returns:

API result data object. Contains zero status and a list of cache names, non-zero status and an error description otherwise.

pygridgain.api.cache_config.cache_get_or_create(connection: Connection, name: str, query_id=None) → APIResult

Creates a cache with a given name. Does nothing if the cache exists.

Parameters:
  • connection – connection to GridGain server,
  • name – cache name,
  • query_id – (optional) a value generated by client and returned as-is in response.query_id. When the parameter is omitted, a random value is generated,
Returns:

API result data object. Contains zero status if a cache is created successfully, non-zero status and an error description otherwise.

pygridgain.api.cache_config.cache_get_or_create_with_config(connection: Connection, cache_props: dict, query_id=None) → APIResult

Creates cache with provided configuration. Does nothing if the name is already in use.

Parameters:
  • connection – connection to GridGain server,
  • cache_props – cache configuration properties to create cache with in form of dictionary {property code: python value}. You must supply at least name (PROP_NAME),
  • query_id – (optional) a value generated by client and returned as-is in response.query_id. When the parameter is omitted, a random value is generated,
Returns:

API result data object. Contains zero status if cache was created, non-zero status and an error description otherwise.

pygridgain.api.cache_config.compact_cache_config(cache_config: dict) → dict

This is to make cache config read/write-symmetrical.

Parameters:cache_config – dict of cache config properties, like {‘is_onheapcache_enabled’: 1},
Returns:the same dict, but with property codes as keys, like {PROP_IS_ONHEAPCACHE_ENABLED: 1}.

pygridgain.api.key_value module

pygridgain.api.key_value.cache_clear(connection: Connection, cache: Union[str, int], binary: bool = False, query_id: Union[int, NoneType] = None) → APIResult

Clears the cache without notifying listeners or cache writers.

Parameters:
  • connection – connection to GridGain server,
  • cache – name or ID of the cache,
  • binary – (optional) pass True to keep the value in binary form. False by default,
  • query_id – (optional) a value generated by client and returned as-is in response.query_id. When the parameter is omitted, a random value is generated,
Returns:

API result data object. Contains zero status on success, non-zero status and an error description otherwise.

pygridgain.api.key_value.cache_clear_key(connection: Connection, cache: Union[str, int], key: Any, key_hint: GridGainDataType = None, binary: bool = False, query_id: Union[int, NoneType] = None) → APIResult

Clears the cache key without notifying listeners or cache writers.

Parameters:
  • connection – connection to GridGain server,
  • cache – name or ID of the cache,
  • key – key for the cache entry,
  • key_hint – (optional) GridGain data type, for which the given key should be converted,
  • binary – (optional) pass True to keep the value in binary form. False by default,
  • query_id – (optional) a value generated by client and returned as-is in response.query_id. When the parameter is omitted, a random value is generated,
Returns:

API result data object. Contains zero status on success, non-zero status and an error description otherwise.

pygridgain.api.key_value.cache_clear_keys(connection: Connection, cache: Union[str, int], keys: list, binary: bool = False, query_id: Union[int, NoneType] = None) → APIResult

Clears the cache keys without notifying listeners or cache writers.

Parameters:
  • connection – connection to GridGain server,
  • cache – name or ID of the cache,
  • keys – list of keys or tuples of (key, key_hint),
  • binary – (optional) pass True to keep the value in binary form. False by default,
  • query_id – (optional) a value generated by client and returned as-is in response.query_id. When the parameter is omitted, a random value is generated,
Returns:

API result data object. Contains zero status on success, non-zero status and an error description otherwise.

pygridgain.api.key_value.cache_contains_key(connection: Connection, cache: Union[str, int], key: Any, key_hint: GridGainDataType = None, binary: bool = False, query_id: Union[int, NoneType] = None) → APIResult

Returns a value indicating whether given key is present in cache.

Parameters:
  • connection – connection to GridGain server,
  • cache – name or ID of the cache,
  • key – key for the cache entry. Can be of any supported type,
  • key_hint – (optional) GridGain data type, for which the given key should be converted,
  • binary – pass True to keep the value in binary form. False by default,
  • query_id – a value generated by client and returned as-is in response.query_id. When the parameter is omitted, a random value is generated,
Returns:

API result data object. Contains zero status and a bool value retrieved on success: True when key is present, False otherwise, non-zero status and an error description on failure.

pygridgain.api.key_value.cache_contains_keys(connection: Connection, cache: Union[str, int], keys: Iterable[T_co], binary: bool = False, query_id: Union[int, NoneType] = None) → APIResult

Returns a value indicating whether all given keys are present in cache.

Parameters:
  • connection – connection to GridGain server,
  • cache – name or ID of the cache,
  • keys – a list of keys or (key, type hint) tuples,
  • binary – pass True to keep the value in binary form. False by default,
  • query_id – a value generated by client and returned as-is in response.query_id. When the parameter is omitted, a random value is generated,
Returns:

API result data object. Contains zero status and a bool value retrieved on success: True when all keys are present, False otherwise, non-zero status and an error description on failure.

pygridgain.api.key_value.cache_get(connection: Connection, cache: Union[str, int], key: Any, key_hint: GridGainDataType = None, binary: bool = False, query_id: Union[int, NoneType] = None) → APIResult

Retrieves a value from cache by key.

Parameters:
  • connection – connection to GridGain server,
  • cache – name or ID of the cache,
  • key – key for the cache entry. Can be of any supported type,
  • key_hint – (optional) GridGain data type, for which the given key should be converted,
  • binary – (optional) pass True to keep the value in binary form. False by default,
  • query_id – (optional) a value generated by client and returned as-is in response.query_id. When the parameter is omitted, a random value is generated,
Returns:

API result data object. Contains zero status and a value retrieved on success, non-zero status and an error description on failure.

pygridgain.api.key_value.cache_get_all(connection: Connection, cache: Union[str, int], keys: Iterable[T_co], binary: bool = False, query_id: Union[int, NoneType] = None) → APIResult

Retrieves multiple key-value pairs from cache.

Parameters:
  • connection – connection to GridGain server,
  • cache – name or ID of the cache,
  • keys – list of keys or tuples of (key, key_hint),
  • binary – (optional) pass True to keep the value in binary form. False by default,
  • query_id – (optional) a value generated by client and returned as-is in response.query_id. When the parameter is omitted, a random value is generated,
Returns:

API result data object. Contains zero status and a dict, made of retrieved key-value pairs, non-zero status and an error description on failure.

pygridgain.api.key_value.cache_get_and_put(connection: Connection, cache: Union[str, int], key: Any, value: Any, key_hint: GridGainDataType = None, value_hint: GridGainDataType = None, binary: bool = False, query_id: Union[int, NoneType] = None) → APIResult

Puts a value with a given key to cache, and returns the previous value for that key, or null value if there was not such key.

Parameters:
  • connection – connection to GridGain server,
  • cache – name or ID of the cache,
  • key – key for the cache entry. Can be of any supported type,
  • value – value for the key,
  • key_hint – (optional) GridGain data type, for which the given key should be converted,
  • value_hint – (optional) GridGain data type, for which the given value should be converted.
  • binary – pass True to keep the value in binary form. False by default,
  • query_id – a value generated by client and returned as-is in response.query_id. When the parameter is omitted, a random value is generated,
Returns:

API result data object. Contains zero status and an old value or None if a value is written, non-zero status and an error description in case of error.

pygridgain.api.key_value.cache_get_and_put_if_absent(connection: Connection, cache: Union[str, int], key: Any, value: Any, key_hint: GridGainDataType = None, value_hint: GridGainDataType = None, binary: bool = False, query_id: Union[int, NoneType] = None) → APIResult

Puts a value with a given key to cache only if the key does not already exist.

Parameters:
  • connection – connection to GridGain server,
  • cache – name or ID of the cache,
  • key – key for the cache entry. Can be of any supported type,
  • value – value for the key,
  • key_hint – (optional) GridGain data type, for which the given key should be converted,
  • value_hint – (optional) GridGain data type, for which the given value should be converted.
  • binary – (optional) pass True to keep the value in binary form. False by default,
  • query_id – (optional) a value generated by client and returned as-is in response.query_id. When the parameter is omitted, a random value is generated,
Returns:

API result data object. Contains zero status and an old value or None on success, non-zero status and an error description otherwise.

pygridgain.api.key_value.cache_get_and_remove(connection: Connection, cache: Union[str, int], key: Any, key_hint: GridGainDataType = None, binary: bool = False, query_id: Union[int, NoneType] = None) → APIResult

Removes the cache entry with specified key, returning the value.

Parameters:
  • connection – connection to GridGain server,
  • cache – name or ID of the cache,
  • key – key for the cache entry. Can be of any supported type,
  • key_hint – (optional) GridGain data type, for which the given key should be converted,
  • binary – pass True to keep the value in binary form. False by default,
  • query_id – a value generated by client and returned as-is in response.query_id. When the parameter is omitted, a random value is generated,
Returns:

API result data object. Contains zero status and an old value or None, non-zero status and an error description otherwise.

pygridgain.api.key_value.cache_get_and_replace(connection: Connection, cache: Union[str, int], key: Any, value: Any, key_hint: GridGainDataType = None, value_hint: GridGainDataType = None, binary: bool = False, query_id: Union[int, NoneType] = None) → APIResult

Puts a value with a given key to cache, returning previous value for that key, if and only if there is a value currently mapped for that key.

Parameters:
  • connection – connection to GridGain server,
  • cache – name or ID of the cache,
  • key – key for the cache entry. Can be of any supported type,
  • value – value for the key,
  • key_hint – (optional) GridGain data type, for which the given key should be converted,
  • value_hint – (optional) GridGain data type, for which the given value should be converted.
  • binary – pass True to keep the value in binary form. False by default,
  • query_id – a value generated by client and returned as-is in response.query_id. When the parameter is omitted, a random value is generated,
Returns:

API result data object. Contains zero status and an old value or None on success, non-zero status and an error description otherwise.

pygridgain.api.key_value.cache_get_size(connection: Connection, cache: Union[str, int], peek_modes: int = 0, binary: bool = False, query_id: Union[int, NoneType] = None) → APIResult

Gets the number of entries in cache.

Parameters:
  • connection – connection to GridGain server,
  • cache – name or ID of the cache,
  • peek_modes – (optional) limit count to near cache partition (PeekModes.NEAR), primary cache (PeekModes.PRIMARY), or backup cache (PeekModes.BACKUP). Defaults to all cache partitions (PeekModes.ALL),
  • binary – (optional) pass True to keep the value in binary form. False by default,
  • query_id – (optional) a value generated by client and returned as-is in response.query_id. When the parameter is omitted, a random value is generated,
Returns:

API result data object. Contains zero status and a number of cache entries on success, non-zero status and an error description otherwise.

pygridgain.api.key_value.cache_local_peek(conn: Connection, cache: Union[str, int], key: Any, key_hint: GridGainDataType = None, peek_modes: int = 0, binary: bool = False, query_id: Union[int, NoneType] = None) → APIResult

Peeks at in-memory cached value using default optional peek mode.

This method will not load value from any persistent store or from a remote node.

Parameters:
  • conn – connection: connection to GridGain server,
  • cache – name or ID of the cache,
  • key – entry key,
  • key_hint – (optional) GridGain data type, for which the given key should be converted,
  • peek_modes – (optional) limit count to near cache partition (PeekModes.NEAR), primary cache (PeekModes.PRIMARY), or backup cache (PeekModes.BACKUP). Defaults to all cache partitions (PeekModes.ALL),
  • binary – (optional) pass True to keep the value in binary form. False by default,
  • query_id – (optional) a value generated by client and returned as-is in response.query_id. When the parameter is omitted, a random value is generated,
Returns:

API result data object. Contains zero status and a peeked value (null if not found).

pygridgain.api.key_value.cache_put(connection: Connection, cache: Union[str, int], key: Any, value: Any, key_hint: GridGainDataType = None, value_hint: GridGainDataType = None, binary: bool = False, query_id: Union[int, NoneType] = None) → APIResult

Puts a value with a given key to cache (overwriting existing value if any).

Parameters:
  • connection – connection to GridGain server,
  • cache – name or ID of the cache,
  • key – key for the cache entry. Can be of any supported type,
  • value – value for the key,
  • key_hint – (optional) GridGain data type, for which the given key should be converted,
  • value_hint – (optional) GridGain data type, for which the given value should be converted.
  • binary – (optional) pass True to keep the value in binary form. False by default,
  • query_id – (optional) a value generated by client and returned as-is in response.query_id. When the parameter is omitted, a random value is generated,
Returns:

API result data object. Contains zero status if a value is written, non-zero status and an error description otherwise.

pygridgain.api.key_value.cache_put_all(connection: Connection, cache: Union[str, int], pairs: dict, binary: bool = False, query_id: Union[int, NoneType] = None) → APIResult

Puts multiple key-value pairs to cache (overwriting existing associations if any).

Parameters:
  • connection – connection to GridGain server,
  • cache – name or ID of the cache,
  • pairs – dictionary type parameters, contains key-value pairs to save. Each key or value can be an item of representable Python type or a tuple of (item, hint),
  • binary – (optional) pass True to keep the value in binary form. False by default,
  • query_id – (optional) a value generated by client and returned as-is in response.query_id. When the parameter is omitted, a random value is generated,
Returns:

API result data object. Contains zero status if key-value pairs are written, non-zero status and an error description otherwise.

pygridgain.api.key_value.cache_put_if_absent(connection: Connection, cache: Union[str, int], key: Any, value: Any, key_hint: GridGainDataType = None, value_hint: GridGainDataType = None, binary: bool = False, query_id: Union[int, NoneType] = None) → APIResult

Puts a value with a given key to cache only if the key does not already exist.

Parameters:
  • connection – connection to GridGain server,
  • cache – name or ID of the cache,
  • key – key for the cache entry. Can be of any supported type,
  • value – value for the key,
  • key_hint – (optional) GridGain data type, for which the given key should be converted,
  • value_hint – (optional) GridGain data type, for which the given value should be converted.
  • binary – (optional) pass True to keep the value in binary form. False by default,
  • query_id – (optional) a value generated by client and returned as-is in response.query_id. When the parameter is omitted, a random value is generated,
Returns:

API result data object. Contains zero status on success, non-zero status and an error description otherwise.

pygridgain.api.key_value.cache_remove_all(connection: Connection, cache: Union[str, int], binary: bool = False, query_id: Union[int, NoneType] = None) → APIResult

Removes all entries from cache, notifying listeners and cache writers.

Parameters:
  • connection – connection to GridGain server,
  • cache – name or ID of the cache,
  • binary – (optional) pass True to keep the value in binary form. False by default,
  • query_id – (optional) a value generated by client and returned as-is in response.query_id. When the parameter is omitted, a random value is generated,
Returns:

API result data object. Contains zero status on success, non-zero status and an error description otherwise.

pygridgain.api.key_value.cache_remove_if_equals(connection: Connection, cache: Union[str, int], key: Any, sample: Any, key_hint: GridGainDataType = None, sample_hint: GridGainDataType = None, binary: bool = False, query_id: Union[int, NoneType] = None) → APIResult

Removes an entry with a given key if provided value is equal to actual value, notifying listeners and cache writers.

Parameters:
  • connection – connection to GridGain server,
  • cache – name or ID of the cache,
  • key – key for the cache entry,
  • sample – a sample to compare the stored value with,
  • key_hint – (optional) GridGain data type, for which the given key should be converted,
  • sample_hint – (optional) GridGain data type, for whic the given sample should be converted
  • binary – (optional) pass True to keep the value in binary form. False by default,
  • query_id – (optional) a value generated by client and returned as-is in response.query_id. When the parameter is omitted, a random value is generated,
Returns:

API result data object. Contains zero status and a boolean success code, or non-zero status and an error description if something has gone wrong.

pygridgain.api.key_value.cache_remove_key(connection: Connection, cache: Union[str, int], key: Any, key_hint: GridGainDataType = None, binary: bool = False, query_id: Union[int, NoneType] = None) → APIResult

Clears the cache key without notifying listeners or cache writers.

Parameters:
  • connection – connection to GridGain server,
  • cache – name or ID of the cache,
  • key – key for the cache entry,
  • key_hint – (optional) GridGain data type, for which the given key should be converted,
  • binary – (optional) pass True to keep the value in binary form. False by default,
  • query_id – (optional) a value generated by client and returned as-is in response.query_id. When the parameter is omitted, a random value is generated,
Returns:

API result data object. Contains zero status and a boolean success code, or non-zero status and an error description if something has gone wrong.

pygridgain.api.key_value.cache_remove_keys(connection: Connection, cache: Union[str, int], keys: Iterable[T_co], binary: bool = False, query_id: Union[int, NoneType] = None) → APIResult

Removes entries with given keys, notifying listeners and cache writers.

Parameters:
  • connection – connection to GridGain server,
  • cache – name or ID of the cache,
  • keys – list of keys or tuples of (key, key_hint),
  • binary – (optional) pass True to keep the value in binary form. False by default,
  • query_id – (optional) a value generated by client and returned as-is in response.query_id. When the parameter is omitted, a random value is generated,
Returns:

API result data object. Contains zero status on success, non-zero status and an error description otherwise.

pygridgain.api.key_value.cache_replace(connection: Connection, cache: Union[str, int], key: Any, value: Any, key_hint: GridGainDataType = None, value_hint: GridGainDataType = None, binary: bool = False, query_id: Union[int, NoneType] = None) → APIResult

Puts a value with a given key to cache only if the key already exist.

Parameters:
  • connection – connection to GridGain server,
  • cache – name or ID of the cache,
  • key – key for the cache entry. Can be of any supported type,
  • value – value for the key,
  • key_hint – (optional) GridGain data type, for which the given key should be converted,
  • value_hint – (optional) GridGain data type, for which the given value should be converted.
  • binary – pass True to keep the value in binary form. False by default,
  • query_id – a value generated by client and returned as-is in response.query_id. When the parameter is omitted, a random value is generated,
Returns:

API result data object. Contains zero status and a boolean success code, or non-zero status and an error description if something has gone wrong.

pygridgain.api.key_value.cache_replace_if_equals(connection: Connection, cache: Union[str, int], key: Any, sample: Any, value: Any, key_hint: GridGainDataType = None, sample_hint: GridGainDataType = None, value_hint: GridGainDataType = None, binary: bool = False, query_id: Union[int, NoneType] = None) → APIResult

Puts a value with a given key to cache only if the key already exists and value equals provided sample.

Parameters:
  • connection – connection to GridGain server,
  • cache – name or ID of the cache,
  • key – key for the cache entry,
  • sample – a sample to compare the stored value with,
  • value – new value for the given key,
  • key_hint – (optional) GridGain data type, for which the given key should be converted,
  • sample_hint – (optional) GridGain data type, for whic the given sample should be converted
  • value_hint – (optional) GridGain data type, for which the given value should be converted,
  • binary – (optional) pass True to keep the value in binary form. False by default,
  • query_id – (optional) a value generated by client and returned as-is in response.query_id. When the parameter is omitted, a random value is generated,
Returns:

API result data object. Contains zero status and a boolean success code, or non-zero status and an error description if something has gone wrong.

pygridgain.api.result module

class pygridgain.api.result.APIResult(response: Response)

Bases: object

Dataclass which represents the result of API request.

Fields are:

  • status: request status code. 0 if successful,
  • message: ‘Success’ if status == 0, verbatim error description otherwise,
  • value: return value or None.
__init__(response: Response)

Initialize self. See help(type(self)) for accurate signature.

message = 'Success'
value = None

pygridgain.api.sql module

Only key-value queries (scan queries) are implemented. SQL part is still in progress.

pygridgain.api.sql.resource_close(conn: Connection, cursor: int, query_id: int = None) → pygridgain.api.result.APIResult

Closes a resource, such as query cursor.

Parameters:
  • conn – connection to GridGain server,
  • cursor – cursor ID,
  • query_id – (optional) a value generated by client and returned as-is in response.query_id. When the parameter is omitted, a random value is generated,
Returns:

API result data object. Contains zero status on success, non-zero status and an error description otherwise.

pygridgain.api.sql.scan(conn: Connection, cache: Union[str, int], page_size: int, partitions: int = -1, local: bool = False, binary: bool = False, query_id: int = None) → pygridgain.api.result.APIResult

Performs scan query.

Parameters:
  • conn – connection to GridGain server,
  • cache – name or ID of the cache,
  • page_size – cursor page size,
  • partitions – (optional) number of partitions to query (negative to query entire cache),
  • local – (optional) pass True if this query should be executed on local node only. Defaults to False,
  • binary – (optional) pass True to keep the value in binary form. False by default,
  • query_id – (optional) a value generated by client and returned as-is in response.query_id. When the parameter is omitted, a random value is generated,
Returns:

API result data object. Contains zero status and a value of type dict with results on success, non-zero status and an error description otherwise.

Value dict is of following format:

  • cursor: int, cursor ID,
  • data: dict, result rows as key-value pairs,
  • more: bool, True if more data is available for subsequent ‘scan_cursor_get_page’ calls.

pygridgain.api.sql.scan_cursor_get_page(conn: Connection, cursor: int, query_id: int = None) → pygridgain.api.result.APIResult

Fetches the next scan query cursor page by cursor ID that is obtained from scan function.

Parameters:
  • conn – connection to GridGain server,
  • cursor – cursor ID,
  • query_id – (optional) a value generated by client and returned as-is in response.query_id. When the parameter is omitted, a random value is generated,
Returns:

API result data object. Contains zero status and a value of type dict with results on success, non-zero status and an error description otherwise.

Value dict is of following format:

  • data: dict, result rows as key-value pairs,
  • more: bool, True if more data is available for subsequent ‘scan_cursor_get_page’ calls.

pygridgain.api.sql.sql(conn: Connection, cache: Union[str, int], table_name: str, query_str: str, page_size: int, query_args=None, distributed_joins: bool = False, replicated_only: bool = False, local: bool = False, timeout: int = 0, binary: bool = False, query_id: int = None) → pygridgain.api.result.APIResult

Executes an SQL query over data stored in the cluster. The query returns the whole record (key and value).

Parameters:
  • conn – connection to GridGain server,
  • cache – name or ID of the cache,
  • table_name – name of a type or SQL table,
  • query_str – SQL query string,
  • page_size – cursor page size,
  • query_args – (optional) query arguments,
  • distributed_joins – (optional) distributed joins. Defaults to False,
  • replicated_only – (optional) whether query contains only replicated tables or not. Defaults to False,
  • local – (optional) pass True if this query should be executed on local node only. Defaults to False,
  • timeout – (optional) non-negative timeout value in ms. Zero disables timeout (default),
  • binary – (optional) pass True to keep the value in binary form. False by default,
  • query_id – (optional) a value generated by client and returned as-is in response.query_id. When the parameter is omitted, a random value is generated,
Returns:

API result data object. Contains zero status and a value of type dict with results on success, non-zero status and an error description otherwise.

Value dict is of following format:

  • cursor: int, cursor ID,
  • data: dict, result rows as key-value pairs,
  • more: bool, True if more data is available for subsequent ‘sql_get_page’ calls.

pygridgain.api.sql.sql_cursor_get_page(conn: Connection, cursor: int, query_id: int = None) → pygridgain.api.result.APIResult

Retrieves the next SQL query cursor page by cursor ID from sql.

Parameters:
  • conn – connection to GridGain server,
  • cursor – cursor ID,
  • query_id – (optional) a value generated by client and returned as-is in response.query_id. When the parameter is omitted, a random value is generated,
Returns:

API result data object. Contains zero status and a value of type dict with results on success, non-zero status and an error description otherwise.

Value dict is of following format:

  • data: dict, result rows as key-value pairs,
  • more: bool, True if more data is available for subsequent ‘sql_cursor_get_page’ calls.

pygridgain.api.sql.sql_fields(conn: Connection, cache: Union[str, int], query_str: str, page_size: int, query_args=None, schema: str = None, statement_type: int = 0, distributed_joins: bool = False, local: bool = False, replicated_only: bool = False, enforce_join_order: bool = False, collocated: bool = False, lazy: bool = False, include_field_names: bool = False, max_rows: int = -1, timeout: int = 0, binary: bool = False, query_id: int = None) → pygridgain.api.result.APIResult

Performs SQL fields query.

Parameters:
  • conn – connection to GridGain server,
  • cache – name or ID of the cache,
  • query_str – SQL query string,
  • page_size – cursor page size,
  • query_args – (optional) query arguments. List of values or (value, type hint) tuples,
  • schema – (optional) schema for the query. Defaults to PUBLIC,
  • statement_type

    (optional) statement type. Can be:

    • StatementType.ALL − any type (default),
    • StatementType.SELECT − select,
    • StatementType.UPDATE − update.
  • distributed_joins – (optional) distributed joins. Defaults to False,
  • local – (optional) pass True if this query should be executed on local node only. Defaults to False,
  • replicated_only – (optional) whether query contains only replicated tables or not. Defaults to False,
  • enforce_join_order – (optional) enforce join order. Defaults to False,
  • collocated – (optional) whether your data is co-located or not. Defaults to False,
  • lazy – (optional) lazy query execution. Defaults to False,
  • include_field_names – (optional) include field names in result. Defaults to False,
  • max_rows – (optional) query-wide maximum of rows. Defaults to -1 (all rows),
  • timeout – (optional) non-negative timeout value in ms. Zero disables timeout (default),
  • binary – (optional) pass True to keep the value in binary form. False by default,
  • query_id – (optional) a value generated by client and returned as-is in response.query_id. When the parameter is omitted, a random value is generated,
Returns:

API result data object. Contains zero status and a value of type dict with results on success, non-zero status and an error description otherwise.

Value dict is of following format:

  • cursor: int, cursor ID,
  • data: list, result values,
  • more: bool, True if more data is available for subsequent ‘sql_fields_cursor_get_page’ calls.

pygridgain.api.sql.sql_fields_cursor_get_page(conn: Connection, cursor: int, field_count: int, query_id: int = None) → pygridgain.api.result.APIResult

Retrieves the next query result page by cursor ID from sql_fields.

Parameters:
  • conn – connection to GridGain server,
  • cursor – cursor ID,
  • field_count – a number of fields in a row,
  • query_id – (optional) a value generated by client and returned as-is in response.query_id. When the parameter is omitted, a random value is generated,
Returns:

API result data object. Contains zero status and a value of type dict with results on success, non-zero status and an error description otherwise.

Value dict is of following format:

  • data: list, result values,
  • more: bool, True if more data is available for subsequent ‘sql_fields_cursor_get_page’ calls.

Module contents

This module contains functions, that are (more or less) directly mapped to GridGain binary protocol operations. Read more:

https://apacheignite.readme.io/docs/binary-client-protocol#section-client-operations

When the binary client protocol changes, these functions also change. For stable end user API see pygridgain.client module.