Retrieving PGQL-on-RDBMS results
Retrieving results after executing a PGQL-on-RDBMS query can be done using the PgqlResultSet class.
Please note that this functionality is different from the one included in PyPGX package. For more details look into the PGQL on RDBMS documentation.
- class opg4py.pgql.PgqlResultSet(java_pgql_result_set)
- Wrapper class for oracle.pg.rdbms.pgql.PgqlResultSet. - absolute(row)
- Move the cursor to the given row number in this ResultSet object. - If the row number is positive, the cursor moves to the given row number with respect to the beginning of the result set. The first row is 1, so absolute(1) moves the cursor to the first row. - If the row number is negative, the cursor moves to the given row number with respect to the end of the result set. So absolute(-1) moves the cursor to the last row. - Parameters
- row – Row to move to 
- Returns
- True if the cursor is moved to a position in the ResultSet object; False if the cursor is moved before the first or after the last row 
- Return type
- bool 
 
 - after_last()
- Place the cursor after the last row. - Return type
- None 
 
 - before_first()
- Set the cursor before the first row. - Return type
- None 
 
 - close()
- Free resources on the server taken up by this result_set object. - Return type
- None 
 
 - fetchall()
- Fetch all (remaining) rows of a query result, returning them as a list of tuples. An empty list is returned if no more rows are available. - Returns
- A list of tuples with all (remaining) rows of a query result 
- Return type
- List[tuple] 
 
 - fetchmany(num_rows=1)
- Fetch the next set of rows of a query result, returning a list of tuples. An empty list is returned if no more rows are available. - Returns
- A list of tuples with the next set of rows of a query result 
- Parameters
- num_rows (int) – 
- Return type
- List[tuple] 
 
 - fetchone()
- Fetch the next row of a query result set, returning a single tuple or None when no more data is available. - Returns
- A single tuple with the next row of a query result 
- Return type
- tuple 
 
 - first()
- Move the cursor to the first row in the result set. - Returns
- True if the cursor points to a valid row; False if the result set does not have any results 
- Return type
- bool 
 
 - get(element)
- Get the value of the designated element by element index or name. - Parameters
- element (Union[str, int]) – Integer or string representing index or name 
- Returns
- Content of cell 
- Return type
- Any 
 
 - get_boolean(element)
- Get the value of the designated element by element index or name as a Boolean. - Parameters
- element (Union[str, int]) – Integer or String representing index or name 
- Returns
- Boolean 
- Return type
- Optional[bool] 
 
 - get_date(element)
- Get the value of the designated element by element index or name as a datetime Date. - Parameters
- element (Union[str, int]) – Integer or String representing index or name 
- Returns
- datetime.date 
- Return type
- Optional[date] 
 
 - get_float(element)
- Get the value of the designated element by element index or name as a Float. - Parameters
- element (Union[str, int]) – Integer or String representing index or name 
- Returns
- Float 
- Return type
- Optional[float] 
 
 - get_integer(element)
- Get the value of the designated element by element index or name as an Integer. - Parameters
- element (Union[str, int]) – Integer or String representing index or name 
- Returns
- Integer 
- Return type
- Optional[int] 
 
 - get_list(element)
- Get the value of the designated element by element index or name as a List. - Parameters
- element (Union[str, int]) – Integer or String representing index or name 
- Returns
- List 
- Return type
- Optional[List[str]] 
 
 - get_metadata()
- Get the ResultSet MetaData. - Returns
- PgqlResultSetMetaData 
- Return type
 
 - get_row(row)
- Get row from result_set. - Parameters
- row – Row index 
- Return type
- Any 
 
 - get_slice(start, stop, step=1)
- Get slice from result_set. - Parameters
- start (int) – Start index 
- stop (int) – Stop index 
- step (int) – Step size 
 
- Return type
- List[list] 
 
 - get_string(element)
- Get the value of the designated element by element index or name as a String. - Parameters
- element (Union[str, int]) – Integer or String representing index or name 
- Returns
- String 
- Return type
- Optional[str] 
 
 - get_time(element)
- Get the value of the designated element by element index or name as a datetime Time. - Parameters
- element (Union[str, int]) – Integer or String representing index or name 
- Returns
- datetime.time 
- Return type
- Optional[time] 
 
 - get_time_with_timezone(element)
- Get the value of the designated element by element index or name as a datetime Time with timezone. - Parameters
- element (Union[str, int]) – Integer or String representing index or name 
- Returns
- datetime.time 
- Return type
- Optional[time] 
 
 - get_timestamp(element)
- Get the value of the designated element by element index or name as a Datetime. - Parameters
- element (Union[str, int]) – Integer or String representing index or name 
- Returns
- datetime.datetime 
- Return type
- Optional[datetime] 
 
 - get_timestamp_with_timezone(element)
- Get the value of the designated element by element index or name as a Datetime with timezone. - Parameters
- element (Union[str, int]) – Integer or String representing index or name 
- Returns
- datetime.datetime 
- Return type
- Optional[datetime] 
 
 - get_value_type(element)
- Get the type of value of the designated element by element index or name as an Integer. - Parameters
- element – Integer or String representing index or name 
- Returns
- Integer 
- Return type
- int 
 
 - get_vertex_labels(element)
- Get the value of the designated element by element index or name as a list of labels. - Parameters
- element (Union[str, int]) – Integer or String representing index or name 
- Returns
- list 
- Return type
- List[str] 
 
 - last()
- Move the cursor to the last row in the result set. - Returns
- True if the cursor points to a valid row; False if the result set does not have any results 
- Return type
- bool 
 
 - next()
- Move the cursor forward one row from its current position. - Returns
- True if the cursor points to a valid row; False if the new cursor is positioned after the last row 
- Return type
- bool 
 
 - previous()
- Move the cursor to the previous row from its current position. - Returns
- True if the cursor points to a valid row; False if the new cursor is positioned before the first row 
- Return type
- bool 
 
 - print(file=None, num_results=1000, start=0)
- Print the result set. - Parameters
- file (Optional[TextIO]) – File to which results are printed (default is - sys.stdout)
- num_results (int) – Number of results to be printed 
- start (int) – Index of the first result to be printed 
 
- Return type
- None 
 
 - relative(rows)
- Move the cursor a relative number of row with respect to the current position. - Note a negative number will move the cursor backwards. - Note: Calling relative(1) is equal to next() and relative(-1) is equal to previous. Calling relative(0) is possible when the cursor is positioned at a row, not when it is positioned before the first or after the last row. However, relative(0) will not update the position of the cursor. - Parameters
- rows – Relative number of rows to move from current position 
- Returns
- True if the cursor is moved to a position in the ResultSet object; False if the cursor is moved before the first or after the last row 
- Return type
- bool 
 
 - to_pandas()
- Convert to pandas DataFrame (this method requires pandas). - Returns
- PgqlResultSet as a Pandas Dataframe