2. Creating a PGQL-on-RDBMS statement¶
The following classes can be used to create PGQL statements and prepared statements accordingly.
- class opg4py.pgql.PgqlStatement(java_pgql_statement)
Wrapper class for oracle.pg.rdbms.pgql.PgqlStatement
- cancel()
Allows to cancel currently running execute operation. Note that cancel does not rollback already executed modifications.
Throws: oracle.pgql.lang.PgqlException - When an error occurs while canceling current operation.
- close()
Releases this PgqlStatment’s database and JDBC resources.
Closing this PgqlStatement will close all PgqlResultSets that were created from it.
Throws: oracle.pgql.lang.PgqlException
- execute(pgql, parallel=0, dynamic_sampling=2, match_options=None, options=None)
Executes a PGQL Query, Modify or Create/Drop operation on this instance’s property graph.
Supported query options (matchOptions) are the same as those for executeQuery.
Supported modify options are:
STREAMING=T Use result sets instead of temporary tables to perform the update.
AUTO_COMMIT=F Do not commit after performing the modify operation.
DELETE_CASCADE=F Do not delete incoming/outgoing edges when deleting a vertex.
- Parameters
pgql – the PGQL modify to execute
parallel – the degree of parallelism to use for query and update execution
dynamic_sampling – the value for dynamic sampling
match_options – additional options used to influence query translation and execution
options – additional options used to influence modify translation and execution
- Returns
True if the provided PGQL query is a select, false for other statements
- Throws:
PgqlToSqlException - if a server-side error occurs during translation or SQL execution oracle.pgql.lang.PgqlException - if a server-side error occurs or this method is called on a closed Statement
- execute_query(pgql, timeout=0, parallel=0, dynamic_sampling=2, max_results=- 1, options=None)
Translates this instance’s PGQL statement into a SQL statement and executes the SQL against this instance’s property graph.
Supported query options are:
USE_RW=F Use CONNECT BY instead of recursive WITH for unbounded path traversals.
MAX_PATH_LEN=n Traverse at most n hops when evaluating unbounded path traversals.
EDGE_SET_PARTIAL=T Fetch properties for each start and end vertex found when reading edges from the query result.
- Parameters
pgql – the PGQL query to execute
timeout – the number of seconds for query execution to finish
parallel – the degree of parallelism to use for query execution
dynamic_sampling – the value for dynamic sampling
max_results – the maximum number of rows returned
options – additional options used to influence query translation and execution
- Returns
a PgqlResultSet object with the result of the provided PGQL query
- Throws:
PgqlToSqlException - if a server-side error occurs during translation or SQL execution oracle.pgql.lang.PgqlException - if a server-side error occurs or this method is called on a closed Statement
- get_batch_size()
Get the number of commands that should be batched when executing updates :return: the update batch size
- get_fetch_size()
Get the the number of rows that should be fetched from the database when more rows are needed for a query result. :return: the query fetch size
- get_modify_count()
Get the number of rows that were modified by last execute operation :return: The number of rows modified
- get_result_set()
Retrieve the current result as a PgqlResultSet object.
This method should be called only once per result.
- Returns
Current result as a ResultSet object or null if the query is not a SELECT query
- set_batch_size(batch_size)
Set the number of commands that should be batched when executing updates :param batch_size: the update batch size
- set_fetch_size(fetch_size)
Set the the number of rows that should be fetched from the database when more rows are needed for a query result. :param fetch_size: the query fetch size
- translate_query(pgql, parallel=0, dynamic_sampling=2, max_results=- 1, options=None)
Translates this instance’s PGQL statement into a SQL statement.
Supported query options are:
USE_RW=F Use CONNECT BY instead of recursive WITH for unbounded path traversals.
MAX_PATH_LEN=n Traverse at most n hops when evaluating unbounded path traversals.
EDGE_SET_PARTIAL=T Fetch properties for each start and end vertex found when reading edges from the query result.
- Parameters
pgql – the PGQL query to translate
parallel – the degree of parallelism to use for query execution
dynamic_sampling – the value for dynamic sampling
max_results – the maximum number of rows returned
options – additional options used to influence query translation
- Returns
a PgqlSqlTrans object with the SQL translation and column metadata for the provided PGQL query
- Throws:
PgqlToSqlException - if a server-side error occurs during translation oracle.pgql.lang.PgqlException - if a server-side error occurs or this method is called on a closed Statement
- translate_statement(pgql, parallel=0, dynamic_sampling=2, max_results=- 1, match_options=None, options=None)
Translates the given PGQL statement into a series of SQL statements.
- Parameters
pgql – the PGQL statement to translate
parallel – the degree of parallelism to use for query execution
dynamic_sampling – the value for dynamic sampling
max_results – the maximum number of rows returned
match_options – additional options used to influence query translation and execution
options – additional options used to influence DDL/DML translation and execution
- Returns
the SQL statements and metadata necessary to execute the provided SQL statement
- Throws:
PgqlToSqlException - if a server-side error occurs during translation oracle.pgql.lang.PgqlException - if a server-side error occurs or this method is called on a closed Statement
- class opg4py.pgql.PgqlPreparedStatement(java_pgql_prepared_statement)
Wrapper class for oracle.pg.rdbms.pgql.PgqlPreparedStatement
- execute(parallel=0, dynamic_sampling=2, match_options=None, options=None)
Executes a PGQL Query, Modify or Create/Drop operation on this instance’s property graph.
Supported query options (matchOptions) are the same as those for executeQuery.
Supported modify options are:
STREAMING=T Use result sets instead of temporary tables to perform the update.
AUTO_COMMIT=F Do not commit after performing the modify operation.
DELETE_CASCADE=F Do not delete incoming/outgoing edges when deleting a vertex.
- Parameters
parallel – the degree of parallelism to use for query and update execution
dynamic_sampling – the value for dynamic sampling
match_options – additional options used to influence query translation and execution
options – additional options used to influence modify translation and execution
- Returns
True if the provided PGQL query is a select, false for other statements
- Throws:
PgqlToSqlException - if a server-side error occurs during translation or SQL execution oracle.pgql.lang.PgqlException - if a server-side error occurs or this method is called on a closed Statement
- execute_query(timeout=0, parallel=0, dynamic_sampling=2, max_results=- 1, options=None)
Translates this instance’s PGQL statement into a SQL statement and executes the SQL against this instance’s property graph.
Supported query options are:
USE_RW=F Use CONNECT BY instead of recursive WITH for unbounded path traversals.
MAX_PATH_LEN=n Traverse at most n hops when evaluating unbounded path traversals.
EDGE_SET_PARTIAL=T Fetch properties for each start and end vertex found when reading edges from the query result.
- Parameters
timeout – the number of seconds for query execution to finish
parallel – the degree of parallelism to use for query execution
dynamic_sampling – the value for dynamic sampling
max_results – the maximum number of rows returned
options – additional options used to influence query translation and execution
- Returns
a PgqlResultSet object with the result of the provided PGQL query
- Throws:
PgqlToSqlException - if a server-side error occurs during translation or SQL execution oracle.pgql.lang.PgqlException - if a server-side error occurs or this method is called on a closed Statement
- set_array(param_index, value)
Sets the designated parameter to the given Java List value.
- Parameters
param_index – the first parameter is 1, the second is 2, …
- Param
value: the parameter value
- set_boolean(param_index, value)
Sets the designated parameter to the given Java boolean value.
- Parameters
param_index – the first parameter is 1, the second is 2, …
- Param
value: the parameter value
- set_double(param_index, value)
Sets the designated parameter to the given Java double value.
- Parameters
param_index – the first parameter is 1, the second is 2, …
- Param
value: the parameter value
- set_float(param_index, value)
Sets the designated parameter to the given Java float value.
- Parameters
param_index – the first parameter is 1, the second is 2, …
- Param
value: the parameter value
- set_int(param_index, value)
Sets the designated parameter to the given Java int value.
- Parameters
param_index – the first parameter is 1, the second is 2, …
- Param
value: the parameter value
- set_long(param_index, value)
Sets the designated parameter to the given Java long value.
- Parameters
param_index – the first parameter is 1, the second is 2, …
- Param
value: the parameter value
- set_string(param_index, value)
Sets the designated parameter to the given Java String value.
- Parameters
param_index – the first parameter is 1, the second is 2, …
- Param
value: the parameter value
- set_timestamp(param_index, value)
Sets the designated parameter to the given Java Timestamp value.
Timestamp values are assumed to be in Coordinated Universal Time (UTC).
- Parameters
param_index – the first parameter is 1, the second is 2, …
- Param
value: the parameter value