pyignite.api.sql module¶
Only key-value queries (scan queries) are implemented. SQL part is still in progress.
-
pyignite.api.sql.
resource_close
(connection: Connection, cursor: int, query_id=None) → pyignite.api.result.APIResult¶ Closes a resource, such as query cursor.
Parameters: - connection – connection to Ignite 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.
-
pyignite.api.sql.
scan
(connection: Connection, cache: Union[str, int], page_size: int, partitions: int = -1, local: bool = False, binary: bool = False, query_id=None) → pyignite.api.result.APIResult¶ Performs scan query.
Parameters: - connection – connection to Ignite 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.
-
pyignite.api.sql.
scan_cursor_get_page
(connection: Connection, cursor: int, query_id=None) → pyignite.api.result.APIResult¶ Fetches the next scan query cursor page by cursor ID that is obtained from scan function.
Parameters: - connection – connection to Ignite 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.
-
pyignite.api.sql.
sql
(connection: 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=None) → pyignite.api.result.APIResult¶ Executes an SQL query over data stored in the cluster. The query returns the whole record (key and value).
Parameters: - connection – connection to Ignite 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.
-
pyignite.api.sql.
sql_cursor_get_page
(connection: Connection, cursor: int, query_id=None) → pyignite.api.result.APIResult¶ Retrieves the next SQL query cursor page by cursor ID from sql.
Parameters: - connection – connection to Ignite 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.
-
pyignite.api.sql.
sql_fields
(connection: 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=None) → pyignite.api.result.APIResult¶ Performs SQL fields query.
Parameters: - connection – connection to Ignite 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.
-
pyignite.api.sql.
sql_fields_cursor_get_page
(connection: Connection, cursor: int, field_count: int, query_id=None) → pyignite.api.result.APIResult¶ Retrieves the next query result page by cursor ID from sql_fields.
Parameters: - connection – connection to Ignite 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.