Query API¶
Describes how to access the results from a query.
-
class
tgdb.query.
TGQuery
¶ Used for parameterized queries.
-
abstract
close
()¶ Close the query and clean up the compiled query on the server side.
- Returns
Nothing
- Return type
-
abstract
execute
() → tgdb.query.TGResultSet¶ Execute this query with the current parameter list.
- Returns
The results from executing this query with the given parameters.
- Return type
-
abstract property
option
¶ Gets the query options for this query.
- Returns
The options for this query.
- Return type
-
abstract
-
class
tgdb.query.
TGQueryCommand
(value)¶ The query commands that the server recognizes.
-
class
tgdb.query.
TGQueryErrorStatus
(value)¶ This class converts a query result from an integer to the meaning behind it.
-
classmethod
fromId
(id: int)¶ Converts an integer identifier to a
TGQueryErrorStatus
.- Parameters
id (int) – The integer identifier that the server has for a given result.
- Returns
The error status in a more readable and supportable manner.
- Return type
-
classmethod
-
exception
tgdb.query.
TGQueryException
(result: int, msg: Optional[str])¶ Represents an exception occurring in the execution of a query.
-
property
errStatus
¶ Gets the error status.
- Returns
The error status
- Return type
-
property
-
class
tgdb.query.
TGQueryOption
(*args, **kwds)¶ Stores information about the query.
-
sortOrderDesc
: bool¶ -
Whether to sort on the attribute descending or ascending, with True for sort descending and False for ascending (only used when usign TGQL, not Gremlin).
-
sortResultLimit
: int¶ -
The maximum number of objects to return in the result (only used when usign TGQL, not Gremlin).
-
property
edgeExpr
¶ Gets the expression to traverse an edge to another node (only used when usign TGQL, not Gremlin).
- Returns
The expression to traverse an edge to another node (only used when usign TGQL, not Gremlin).
- Return type
-
property
edgeLimit
¶ Represents the maximum number of edges for the server to respond with (only used when using TGQL, not Gremlin).
- Returns
The maximum number of edges from the server.
- Return type
-
property
prefetchSize
¶ Represents the maximum number of objects to fetch during a single request/response to the server.
- Returns
The number of bytes to prefetch.
- Return type
-
property
traversalDepth
¶ Represents the maximum depth of recursion for the query (only used when using TGQL, not Gremlin).
- Returns
Maximum traversal depth
- Return type
-
writeExternal
(os: tgdb.pdu.TGOutputStream, writeSort: bool = False, writeQueryStr: bool = False)¶ Handles communicating the query options with the server.
- Parameters
os – The stream to write this to.
writeSort – Whether to write the sort information.
writeQueryStr – Whether to write the query string options.
-
-
class
tgdb.query.
TGQueryResultDataType
(value)¶ Data type used to describe the metadata of the resulting type of a gremlin query.
-
class
tgdb.query.
TGResultDataDescriptor
¶ The resulting set’s data descriptor.
-
abstract property
attributeType
¶ Gets the attribute type (if this descriptor has type attribute).
- Returns
The attribute type.
- Return type
-
abstract property
containedDataSize
¶ Gets the number of descriptors in this descriptor (should only not be None when this is of type list or path).
- Returns
The number of data types that are sub-types.
- Return type
-
abstract property
containedDescriptors
¶ Gets the descriptors contained by this descriptor. Should only be defined when this is of type list or path.
- Returns
The contained descriptors.
- Return type
-
abstract property
dataType
¶ Gets the data type for this data descriptor.
- Returns
The result data type.
- Return type
-
abstract property
hasConcreteType
¶ Whether this attribute has a concrete type (should be False if this is a composite type, like a list or a map).
- Returns
Whether this descriptor represents a concrete type.
- Return type
-
abstract property
isArray
¶ Whether this descriptor represents an array.
- Returns
Whether this descriptor represents an array.
- Return type
-
abstract property
isMap
¶ Whether this descriptor represents a map.
- Returns
Whether this descriptor represents a map.
- Return type
-
abstract property
keyDescriptor
¶ Gets the descriptor used as the key for this descriptor. Should only be defined when this corresponds to a map.
- Returns
The descriptor for the key.
- Return type
-
abstract property
sysobj
¶ The corresponding system object (if this is of type object).
- Returns
The corresponding system object.
- Return type
-
abstract property
valueDescriptor
¶ Gets the descriptor used as the value for this descriptor. Should only be defined when this corresponds to a map.
- Returns
The descriptor for the value.
- Return type
-
abstract property
-
class
tgdb.query.
TGResultSet
¶ This represents a single query response from the server
It will in the future handle acting like a cursor.
-
abstract property
exceptions
¶ Returns what the server’s exceptions are.
To be either Null or an empty List if there are no exceptions.
- Returns
A list of the exceptions that occurred during recovery of the data requested by the query.
- Return type
-
abstract property
hasExceptions
¶ Returns whether the server responded with any exceptions.
- Returns
Whether the query caused any exceptions.
- Return type
-
abstract property
metadata
¶ Returns the metadata for this query result set.
- Returns
This queries metadata.
- Return type
-
abstract property
position
¶ The current position of this cursor.
- Returns
The current position.
- Return type
-
abstract property
size
¶ Gets the number of objects returned as an integer.
- Returns
The number of objects in this query.
- Return type
-
abstract
skip
(count)¶ Skips the objects
-
abstract
toCollection
() → List¶ Gets all of the objects as a list
Note: Do not use when the number of objects returned could be large. Would recommend iterating through because of the penalty that Python has with deserializing objects.
- Returns
A list of all of the query results. The types should match up with those described by the metadata.
- Return type
-
abstract property
-
class
tgdb.query.
TGResultSetMetaData
¶ The resulting set’s metadata descriptor.
-
abstract property
annotation
¶ Gets the result type of this result set’s metadata.
- Returns
The annotation for this result. Can be used to determine the language.
- Return type
-
abstract property
resultDataDescriptor
¶ Gets the data descriptor for this result set’s metadata.
- Returns
The result set’s data descriptor.
- Return type
-
abstract property
resultType
¶ Gets the result type of this result set’s metadata.
- Returns
The top level result data type for this result.
- Return type
-
abstract property