4. 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

after_last()

Place the cursor after the last row

before_first()

Set the cursor before the first row

close()

Free resources on the server taken up by this result_set object.

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

get(element)

Get the value of the designated element by element index or name

Parameters

element – Integer or string representing index or name

Returns

Content of cell

get_boolean(element)

Get the value of the designated element by element index or name as a Boolean

Parameters

element – Integer or String representing index or name

Returns

Boolean

get_date(element)

Get the value of the designated element by element index or name as a datetime Date

Parameters

element – Integer or String representing index or name

Returns

datetime.date

get_float(element)

Get the value of the designated element by element index or name as a Float

Parameters

element – Integer or String representing index or name

Returns

Float

get_integer(element)

Get the value of the designated element by element index or name as an Integer

Parameters

element – Integer or String representing index or name

Returns

Integer

get_list(element)

Get the value of the designated element by element index or name as a List

Parameters

element – Integer or String representing index or name

Returns

List

get_string(element)

Get the value of the designated element by element index or name as a String

Parameters

element – Integer or String representing index or name

Returns

String

get_time(element)

Get the value of the designated element by element index or name as a datetime Time

Parameters

element – Integer or String representing index or name

Returns

datetime.time

get_time_with_timezone(element)

Get the value of the designated element by element index or name as a datetime Time that includes timezone

Parameters

element – Integer or String representing index or name

Returns

datetime.time

get_timestamp(element)

Get the value of the designated element by element index or name as a Datetime

Parameters

element – Integer or String representing index or name

Returns

datetime.datetime

get_timestamp_with_timezone(element)

Get the value of the designated element by element index or name as a Datetime that includes timezone

Parameters

element – Integer or String representing index or name

Returns

datetime.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

get_vertex_labels(element)

Get the value of the designated element by element index or name as a list of labels

Parameters

element – Integer or String representing index or name

Returns

list

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

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

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

print(file=None, num_results=1000, start=0)

Print the result set.

Parameters
  • file – File to which results are printed (default is sys.stdout)

  • num_results – Number of results to be printed

  • start – Index of the first result to be printed

relative(rows)

Move the cursor a relative number of row with respect to the current position. 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