Modeling API

Describes how to modify attributes, nodes, and edges, and the Graph metadata.

class tgdb.model.Direction(value)

Direction enum relative to the nodes.

class tgdb.model.DirectionType(value)

The direction for an edge.

classmethod fromId(id: int)

Gets the direction from the integer identifier

class tgdb.model.TGAttribute

This represents an attribute on the database server.

This is analogous to a cell in a relational model.

asBytes()

“Gets the value of this object as a byte array.

Will throw an exception if that conversion does not make sense.

asChars()

“Gets the value of this object as a character array.

Will throw an exception if that conversion does not make sense.

property booleanValue

“Gets the value of this object as a boolean.

Will throw an exception if that conversion does not make sense.

property byteValue

“Gets the value of this object as a byte.

Will throw an exception if that conversion does not make sense.

property charValue

“Gets the value of this object as a character.

Will throw an exception if that conversion does not make sense.

property dateValue

“Gets the value of this object as a date.

Will throw an exception if that conversion does not make sense.

abstract property descriptor

Returns the attribute descriptor of this attribute (analogous to the attribute’s type).

property doubleValue

“Gets the value of this object as a 64-bit float.

Will throw an exception if that conversion does not make sense.

property floatValue

“Gets the value of this object as a 32-bit float.

Will throw an exception if that conversion does not make sense.

property intValue

“Gets the value of this object as a 32-bit integer.

Will throw an exception if that conversion does not make sense.

abstract property isModified

Returns whether this attribute is modifiable.

abstract property isNull

Returns whether this attribute has a null value (True if it’s value is null).

property longValue

“Gets the value of this object as a 64-bit integer.

Will throw an exception if that conversion does not make sense.

property numberValue

“Gets the value of this object as a number.

Will throw an exception if that conversion does not make sense.

property shortValue

“Gets the value of this object as a 16-bit integer.

Will throw an exception if that conversion does not make sense.

property stringValue

“Gets the value of this object as a string.

Will throw an exception if that conversion does not make sense.

property timeValue

“Gets the value of this object as a time.

Will throw an exception if that conversion does not make sense.

property timestampValue

“Gets the value of this object as a timestamp.

Will throw an exception if that conversion does not make sense.

abstract property value

Returns the value of this attribute

class tgdb.model.TGAttributeDescriptor

Each object of this class represents an attribute descriptor in the database.

An attribute descriptor in TIBCO Graph Database acts like a column - a combination of a name and a type. Unlike more traditional relational databases, this attribute descriptor can fit on different types and kinds of objects. For example one attribute descriptor can be used on both edges and nodes, and on different node types and edge types. Also, you can set an attribute on node or edge of a type, even when that type does not include the attribute descriptor.

abstract property id

Returns the identifier of this attribute descriptor

abstract property isArray

Returns whether this attribute descriptor is an array

abstract property isEncrypted

Returns whether this attribute descriptor has encrypted values on the database side.

NOTE: When receiving encrypted attributes from the server, they are only obfuscated, NOT ENCRYPTED. They were only obfuscated to reduce overhead on client’s side. To ensure proper data protection from the server, be sure to use SSL channels instead of plain-text tcp channels. Sending encrypted data to the server is encrypted, even when going over an insecure channel.

abstract property precision

Returns the precision of this attribute descriptor (only if it is of Number type)

abstract property scale

Returns the scale of this attribute descriptor.

abstract property type

Returns the attribute type of this object

class tgdb.model.TGAttributeType(value)

Represents the different type of attributes.

property char

Gets a single-character representation of this attribute. Should correspond to something that a query returns.

classmethod fromTypeChar(charId: str)

Gets the corresponding TGAttributeType based on the character identifier

classmethod fromTypeId(typeId: int)

Gets the corresponding TGAttributeType based on the typeid

classmethod fromTypeName(name)

Gets the corresponding TGAttributeType based on the name of the attribute.

property identifer

Gets the identifier for this attribute.

property shortname

Gets the short-hand name of this attribute type.

class tgdb.model.TGEdge

Represents a single edge.

abstract property directiontype

Gets the direction of this edge.

abstract property fromVertex

Gets the from vertex of this edge, or the vertex that was listed first when adding to the database if this is an undirected or bidirected edge.

abstract property toVertex

Gets the to vertex of this edge, or the vertex that was listed second when adding to the database if this is an undirected or bidirected edge.

abstract property vertices

Gets the vertex endpoints of this edge.

The first node is the from vertex, the second is the to vertex.

class tgdb.model.TGEdgeType

This represents an edge type.

Do not use with anything other than edge entities.

abstract property directiontype

Gets the direction of this edge type.

abstract property fromNodeType

Gets the from node type (or none if one does not exist).

abstract property toNodeType

Gets the to node type (or none if one does not exist).

class tgdb.model.TGEntity

Represents a single entity on the server.

abstract property attributes

Gets the attributes of entity.

abstract property entityKind

Gets the kind of entity.

abstract property entityType

Gets the type of this entity.

abstract getAttribute(key: str)tgdb.model.TGAttribute

Gets a particular attribute of this entity.

abstract property graphMetadata

Gets the graphmetadata.

abstract property isDeleted

Is true if this entity was deleted from the server.

abstract property isNew

Determines whether this entity is a newly created one on this client’s session and has yet to be sent to the server.

abstract property primaryKey

Gets the primary key for this entity.

Only guaranteed to compare equal to another entity when their primary keys match. Other than that, nothing else about the type or what it compares to is guaranteed.

abstract setAttribute(key: str, value: tgdb.model.TGAttribute)

Sets a particular attribute of this entity.

abstract property version

Gets the version of this entity.

class tgdb.model.TGEntityKind(value)

Describes the different kinds of the entities in the database.

classmethod fromKindId(kindid)

Gets the entity kind from an identifier.

class tgdb.model.TGEntityType

Represents a type for an entity on the server.

abstract property attributeDescriptors

Gets the attribute descriptors for this type.

These are only defined because the all of the entities of this type should conceptually share many of these attributes.

abstract getAttributeDescriptor(name)tgdb.model.TGAttributeDescriptor

Gets a particular attribute descriptor (indexed by that attribute descriptor’s name).

abstract property numberEntities

Gets the number of entities

class tgdb.model.TGGraphMetadata

An object representing all of the metadata for this server instance.

This includes all of the node types, edge types, and attribute descriptors.

abstract property attritubeDescriptors

Gets the attribute descriptors as dictionary indexed by their name.

abstract property edgetypes

Gets the edge types as dictionary indexed by their name.

abstract property nodetypes

Gets the node types as dictionary indexed by their name.

abstract property types

Gets the types as dictionary indexed by their identifier.

class tgdb.model.TGGraphObjectFactory

Is a factory for nodes, edges, and keys for the client.

Important to use this instead of directly instantiating the objects on your own.

abstract property connection

Gets the connection GOF.

abstract createCompositeKey(nodetype: Union[str, tgdb.model.TGNodeType])tgdb.model.TGKey

Create a key.

Parameters

nodetype – The nodetype of the node to search for. Either the name of the nodetype (as a string) or the

nodetype itself.

abstract createEdge(fromnode: tgdb.model.TGNode, tonode: tgdb.model.TGNode, dirtype: tgdb.model.DirectionType = <DirectionType.Directed: 1>, edgetype: Union[str, tgdb.model.TGEdgeType] = None)tgdb.model.TGEdge

Create an edge.

Parameters
  • fromnode – The from node for this edge.

  • tonode – The to node for this edge.

  • dirtype – The direction of this node (default: Directed).

  • edgetype – The edgetype of the node to create. Either the name of the edgetype (as a string) or the

edgetype itself. Will overright the dirtype parameter if set to a non-null value (default: None).

abstract createNode(nodetype: Union[str, tgdb.model.TGNodeType])tgdb.model.TGNode

Create a node.

Parameters

nodetype – The nodetype of the node to create. Either the name of the nodetype (as a string) or the

nodetype itself.

abstract property graphmetadata

Gets graph metadata of this GOF.

class tgdb.model.TGIndex

This represents an index definition and all of the configuration aspects for this index.

abstract property attributeDescriptors

Gets the attribute descriptors that form this index (in order).

abstract property blockSize

Gets the size of the data block when the index is stored on disk.

abstract property numEntries

Gets the number of entities in the index.

abstract property onTypes

Gets the types that are currently in this index.

abstract property status

Gets the status of the database

abstract property unique

Gets whether this index is unique

class tgdb.model.TGKey

Represents a key into the database.

Keys must be only on uniquely identifiable attributes with an explicit index or one implicitly created for attributes that are primary keys.

abstract matches(entity: tgdb.model.TGEntity)bool

Determine whether this key matches with the passed entity.

class tgdb.model.TGNode

Represents a single node in the server (or on the client).

abstract property bidirectedEdges

Gets all of the bidirected edges with an endpoint on this node.

abstract property directedEdges

Gets all of the directed edges with an endpoint on this node.

abstract property edges

Gets all of the edges with an endpoint on this node.

abstract getEdges(filter=None) → List

Gets the edges associated with this node.

Parameters

filter – is a filter to base which edges are included.

abstract property primaryKey

Gets the primary key of this node. Only guarantee is that it will always compare true to a node with the same key, and false to a node with a different key.

abstract property undirectedEdges

Gets all of the undirected edges with an endpoint on this node.

class tgdb.model.TGNodeType

This represents a node type.

Specifically for nodes and should not be used with edges or any other kind of entity.

abstract property pkeyAttributeDescriptors

Gets the primary key attribute descriptors.

class tgdb.model.TGPermissionType(value)

This class represents a single role permission, or all of them.

property flag

Gets the bit field that this permission.

classmethod flagFromStr(val: str)int

Converts a flag from a string of shorthand characters into a bit-string of valid permission flags.

classmethod flagToStr(values: FrozenSet)str

Converts a set of permission

classmethod permissionsFromByte(data: int)

Gets the permission type from the byte

property shorthand

Gets the shorthand name of this permission

class tgdb.model.TGPrivilege(value)

This class represents the privileges that a role could possibly have access to. Privileges represent a database-wide entitlement granted to a role that allows database diagnostics, granting/revoking of privileges or permissions, and other entitlements that are not specific to any system type.

property flag

Gets the bitfield index for this privilege.

classmethod flagFromStr(val: str)int

Converts a collection of bits in a string into a bit string representation of those privileges.

classmethod flagToStr(values: FrozenSet)str

Converts a set of privileges into a more-readable string

classmethod privilegesFromInt(data: int)

Converts a bit string into a set of privileges.

classmethod privilegesToInt(data: Union[Iterable, Any])

Convets one or many privileges into a set bit string.

property shorthand

Gets the short-hand string name for this privilege.

class tgdb.model.TGRole

A role is a collection of permissions on specific system types.

abstract property default

Gets the default permissions for this role when no type-specific permission is set.

abstract property permissions

Gets a list of all of the general (non-special) permissions.

abstract property privileges

Gets the privileges. Privileges differ from permissions in that privileges determine database wide abilities like importing/exporting, granting/revoking permissions or privileges, etc.

abstract property syscatalog

Gets the SYSCATALOG permissions for this role. These specify the permissions on creation/reading/updating/ deleting/etc on system types.

class tgdb.model.TGRolePermFlag(value)

This class determines if a role permission designates any role permission.

classmethod flagFromInt(flag: int)

Intended for internal use only.

class tgdb.model.TGRolePermission

Acts as a role’s permissions on a specific attribute descriptor, nodetype, or edgetype.

abstract property flag

Gets the flag for this role permission.

abstract property grantedPerms

Gets the granted permission values for this role-permission.

abstract property revokedPerms

Gets the revoked permission values for this role-permission.

abstract property sysID

Gets the system identifier that corresponds to an attribute descriptor, a nodetype, or an edgetype.

class tgdb.model.TGSPParam
abstract property name

TODO

abstract property paramType

TODO

class tgdb.model.TGSPParamType(value)

An enumeration.

class tgdb.model.TGSPReturnElemType(value)

An enumeration.

class tgdb.model.TGSPReturnType(value)

An enumeration.

class tgdb.model.TGStoredProcedure
abstract property module

TODO

abstract property params

TODO

abstract property returnType

TODO

class tgdb.model.TGSystemObject

Represents a single object type in the graph database.

abstract property id

Returns the identifier of this object type

abstract property name

Returns the name of this object type

abstract property systemType

Returns the kind of type of this object

class tgdb.model.TGSystemType(value)

Describes the various kinds of types that the server recognizes.

classmethod fromValue(value)

Gets the kind of type from the integer identifier.