Python driver API reference
Connection
TypeDB
driver
static driver(address: str, credentials: Credentials, driver_options: DriverOptions) -> Driver
Creates a connection to TypeDB.
Name | Description | Type | Default Value |
---|---|---|---|
|
Address of the TypeDB server. |
|
|
|
The credentials to connect with. |
|
|
|
The connection settings to connect with. |
|
Driver
Unresolved include directive in modules/ROOT/partials/python/api-reference.adoc - include::api-ref::partial$python/connection/TypeDBDriver.adoc[]
Unresolved include directive in modules/ROOT/partials/python/api-reference.adoc - include::api-ref::partial$python/connection/TypeDBCredential.adoc[]
DatabaseManager
Provides access to all database management methods.
all
all() -> List[Database]
Retrieves all databases present on the TypeDB server
List[Database]
driver.databases.all()
contains
contains(name: str) -> bool
Checks if a database with the given name exists
Name | Description | Type | Default Value |
---|---|---|---|
|
The database name to be checked |
|
bool
driver.databases.contains(name)
Database
Name | Type | Description |
---|---|---|
|
|
The database name as a string. |
UserManager
Provides access to all user management methods.
all
all() -> List[User]
Retrieves all users which exist on the TypeDB server.
List[User]
driver.users.all()
contains
contains(username: str) -> bool
Checks if a user with the given name exists.
Name | Description | Type | Default Value |
---|---|---|---|
|
The user name to be checked |
|
bool
driver.users.contains(username)
create
create(username: str, password: str) -> None
Create a user with the given name and password.
Name | Description | Type | Default Value |
---|---|---|---|
|
The name of the user to be created |
|
|
|
The password of the user to be created |
|
None
driver.users.create(username, password)
User
TypeDB user information
Name | Type | Description |
---|---|---|
|
|
Returns the name of this user. |
Session
Unresolved include directive in modules/ROOT/partials/python/api-reference.adoc - include::api-ref::partial$python/session/TypeDBSession.adoc[]
Unresolved include directive in modules/ROOT/partials/python/api-reference.adoc - include::api-ref::partial$python/session/SessionType.adoc[]
Unresolved include directive in modules/ROOT/partials/python/api-reference.adoc - include::api-ref::partial$python/session/TypeDBOptions.adoc[]
Transaction
Unresolved include directive in modules/ROOT/partials/python/api-reference.adoc - include::api-ref::partial$python/transaction/TypeDBTransaction.adoc[]
Answer
Unresolved include directive in modules/ROOT/partials/python/api-reference.adoc - include::api-ref::partial$python/answer/ConceptMapGroup.adoc[]
Unresolved include directive in modules/ROOT/partials/python/api-reference.adoc - include::api-ref::partial$python/answer/ConceptMap.adoc[]
Unresolved include directive in modules/ROOT/partials/python/api-reference.adoc - include::api-ref::partial$python/answer/ValueGroup.adoc[]
Promise
A Promise
represents an asynchronous network operation.
The request it represents is performed immediately. The response is only retrieved once the Promise
is resolve
d.
resolve
resolve() -> T
Retrieves the result of the Promise.
T
promise.resolve()
Unresolved include directive in modules/ROOT/partials/python/api-reference.adoc - include::api-ref::partial$python/answer/Explainables.adoc[]
Unresolved include directive in modules/ROOT/partials/python/api-reference.adoc - include::api-ref::partial$python/answer/Explainable.adoc[]
Unresolved include directive in modules/ROOT/partials/python/api-reference.adoc - include::api-ref::partial$python/answer/Explanation.adoc[]
Concept
Unresolved include directive in modules/ROOT/partials/python/api-reference.adoc - include::api-ref::partial$python/concept/ConceptManager.adoc[]
Concept
as_attribute
as_attribute() -> Attribute
Casts the concept to Attribute
.
Attribute
concept.as_attribute()
as_attribute_type
as_attribute_type() -> AttributeType
Casts the concept to AttributeType
.
AttributeType
concept.as_attribute_type()
as_entity
as_entity() -> Entity
Casts the concept to Entity
.
Entity
concept.as_entity()
as_entity_type
as_entity_type() -> EntityType
Casts the concept to EntityType
.
EntityType
concept.as_entity_type()
as_instance
as_instance() -> Instance
Casts the concept to Instance
.
Instance
concept.as_instance()
as_relation
as_relation() -> Relation
Casts the concept to Relation
.
Relation
concept.as_relation()
as_relation_type
as_relation_type() -> RelationType
Casts the concept to RelationType
.
RelationType
concept.as_relation_type()
as_role_type
as_role_type() -> RoleType
Casts the concept to RoleType
.
RoleType
concept.as_role_type()
as_value
as_value() -> Value
Casts the concept to Value
.
Value
concept.as_value()
get_label
get_label() -> str
Get the label of the concept. If this is an Instance
, return the label of the type of this instance (“unknown” if type fetching is disabled). If this is a Value
, return the label of the value type of the value. If this is a Type
, return the label of the type.
str
concept.get_label()
is_attribute
is_attribute() -> bool
Checks if the concept is an Attribute
.
bool
concept.is_attribute()
is_attribute_type
is_attribute_type() -> bool
Checks if the concept is an AttributeType
.
bool
concept.is_attribute_type()
is_boolean
is_boolean() -> bool
Returns True
if the value which this Concept
holds is of type boolean
or if this Concept
is an AttributeType
of type boolean
. Otherwise, returns False
.
bool
concept.is_boolean()
is_date
is_date() -> bool
Returns True
if the value which this Concept
holds is of type date
or if this Concept
is an AttributeType
of type date
. Otherwise, returns False
.
bool
concept.is_date()
is_datetime
is_datetime() -> bool
Returns True
if the value which this Concept
holds is of type datetime
or if this Concept
is an AttributeType
of type datetime
. Otherwise, returns False
.
bool
concept.is_datetime()
is_datetime_tz
is_datetime_tz() -> bool
Returns True
if the value which this Concept
holds is of type datetime-tz
or if this Concept
is an AttributeType
of type datetime-tz
. Otherwise, returns False
.
bool
concept.is_datetime_tz()
is_decimal
is_decimal() -> bool
Returns True
if the value which this Concept
holds is of type decimal
or if this Concept
is an AttributeType
of type decimal
. Otherwise, returns False
.
bool
concept.is_decimal()
is_double
is_double() -> bool
Returns True
if the value which this Concept
holds is of type double
or if this Concept
is an AttributeType
of type double
. Otherwise, returns False
.
bool
concept.is_double()
is_duration
is_duration() -> bool
Returns True
if the value which this Concept
holds is of type duration
or if this Concept
is an AttributeType
of type duration
. Otherwise, returns False
.
bool
concept.is_duration()
is_entity
is_entity() -> bool
Checks if the concept is an Entity
.
bool
concept.is_entity()
is_entity_type
is_entity_type() -> bool
Checks if the concept is an EntityType
.
bool
concept.is_entity_type()
is_instance
is_instance() -> bool
Checks if the concept is a Instance
.
bool
concept.is_instance()
is_integer
is_integer() -> bool
Returns True
if the value which this Concept
holds is of type integer
or if this Concept
is an AttributeType
of type integer
. Otherwise, returns False
.
bool
concept.is_integer()
is_relation
is_relation() -> bool
Checks if the concept is a Relation
.
bool
concept.is_relation()
is_relation_type
is_relation_type() -> bool
Checks if the concept is a RelationType
.
bool
concept.is_relation_type()
is_role_type
is_role_type() -> bool
Checks if the concept is a RoleType
.
bool
concept.is_role_type()
is_string
is_string() -> bool
Returns True
if the value which this Concept
holds is of type string
or if this Concept
is an AttributeType
of type string
. Otherwise, returns False
.
bool
concept.is_string()
is_struct
is_struct() -> bool
Returns True
if the value which this Concept
holds is of type struct
or if this Concept
is an AttributeType
of type struct
. Otherwise, returns False
.
bool
concept.is_struct()
is_type
is_type() -> bool
Checks if the concept is a Type
.
bool
concept.is_type()
is_value
is_value() -> bool
Checks if the concept is a Value
.
bool
concept.is_value()
try_get_boolean
try_get_boolean() -> bool | None
Returns a boolean
value of this Concept
. If it’s not a Value
or it has another type, raises an exception.
bool | None
value.try_get_boolean()
try_get_date
try_get_date() -> date | None
Returns a timezone naive date
value of this Concept
. If it’s not a Value
or it has another type, raises an exception.
date | None
value.try_get_date()
try_get_datetime
try_get_datetime() -> Datetime | None
Returns a timezone naive datetime
value of this Concept
. If it’s not a Value
or it has another type, raises an exception.
Datetime | None
value.try_get_datetime()
try_get_datetime_tz
try_get_datetime_tz() -> Datetime | None
Returns a timezone naive datetime_tz
value of this Concept
. If it’s not a Value
or it has another type, raises an exception.
Datetime | None
value.try_get_datetime_tz()
try_get_decimal
try_get_decimal() -> Decimal | None
Returns a decimal
value of this Concept
. If it’s not a Value
or it has another type, raises an exception.
Decimal | None
value.try_get_decimal()
try_get_double
try_get_double() -> float | None
Returns a double
value of this Concept
. If it’s not a Value
or it has another type, raises an exception.
float | None
value.try_get_double()
try_get_duration
try_get_duration() -> Duration | None
Returns a timezone naive duration
value of this Concept
. If it’s not a Value
or it has another type, raises an exception.
Duration | None
value.try_get_duration()
try_get_iid
try_get_iid() -> str | None
Retrieves the unique id of the Concept
. Returns None
if absent.
str | None
concept.try_get_iid()
try_get_integer
try_get_integer() -> int | None
Returns a integer
value of this Concept
. If it’s not a Value
or it has another type, raises an exception.
int | None
value.try_get_integer()
try_get_label
try_get_label() -> str | None
Get the label of the concept. If this is an Instance
, return the label of the type of this instance (None
if type fetching is disabled). Returns None
if type fetching is disabled. If this is a Value
, return the label of the value type of the value. If this is a Type
, return the label of the type.
str | None
concept.try_get_label()
try_get_string
try_get_string() -> str | None
Returns a string
value of this Concept
. If it’s not a Value
or it has another type, raises an exception.
str | None
value.try_get_string()
try_get_struct
try_get_struct() -> STRUCT | None
Returns a struct
value of this Concept
represented as a map from field names to values. If it’s not a Value
or it has another type, raises an exception.
STRUCT | None
value.try_get_struct()
Schema
Type
Supertypes:
-
Concept
is_type
is_type() -> bool
Checks if the concept is a Type
.
bool
type_.is_type()
Unresolved include directive in modules/ROOT/partials/python/api-reference.adoc - include::api-ref::partial$python/schema/Label.adoc[]
Unresolved include directive in modules/ROOT/partials/python/api-reference.adoc - include::api-ref::partial$python/schema/ThingType.adoc[]
EntityType
Supertypes:
-
Type
Entity types represent the classification of independent objects in the data model of the business domain.
RelationType
Supertypes:
-
Type
Relation types (or subtypes of the relation root type) represent relationships between types. Relation types have roles.
Other types can play roles in relations if it’s mentioned in their definition.
A relation type must specify at least one role.
RoleType
Supertypes:
-
Type
Roles are special internal types used by relations. We can not create an instance of a role in a database. But we can set an instance of another type (role player) to play a role in a particular instance of a relation type.
Roles allow a schema to enforce logical constraints on types of role players.
AttributeType
Supertypes:
-
Type
Attribute types represent properties that other types can own.
Attribute types have a value type. This value type is fixed and unique for every given instance of the attribute type.
Other types can own an attribute type. That means that instances of these other types can own an instance of this attribute type. This usually means that an object in our domain has a property with the matching value.
Multiple types can own the same attribute type, and different instances of the same type or different types can share ownership of the same attribute instance.
as_attribute_type
as_attribute_type() -> AttributeType
Casts the concept to AttributeType
.
AttributeType
attribute.as_attribute_type()
is_attribute_type
is_attribute_type() -> bool
Checks if the concept is an AttributeType
.
bool
attribute.is_attribute_type()
Unresolved include directive in modules/ROOT/partials/python/api-reference.adoc - include::api-ref::partial$python/schema/Annotation.adoc[]
Unresolved include directive in modules/ROOT/partials/python/api-reference.adoc - include::api-ref::partial$python/schema/Transitivity.adoc[]
Unresolved include directive in modules/ROOT/partials/python/api-reference.adoc - include::api-ref::partial$python/schema/ValueType.adoc[]
Data
Unresolved include directive in modules/ROOT/partials/python/api-reference.adoc - include::api-ref::partial$python/data/Thing.adoc[]
Entity
Supertypes:
-
Instance
Instance of data of an entity type, representing a standalone object that exists in the data model independently.
Entity does not have a value. It is usually addressed by its ownership over attribute instances and/or roles played in relation instances.
as_entity
as_entity() -> Entity
Casts the concept to Entity
.
Entity
entity.as_entity()
get_iid
get_iid() -> str
Retrieves the unique id of the Entity
.
str
entity.get_iid()
Relation
Supertypes:
-
Instance
Relation is an instance of a relation type and can be uniquely addressed by a combination of its type, owned attributes and role players.
as_relation
as_relation() -> Relation
Casts the concept to Relation
.
Relation
relation.as_relation()
get_iid
get_iid() -> str
Retrieves the unique id of the Relation
.
str
relation.get_iid()
Attribute
Supertypes:
-
Instance
Attribute is an instance of the attribute type and has a value. This value is fixed and unique for every given instance of the attribute type.
Attributes can be uniquely addressed by their type and value.
as_attribute
as_attribute() -> Attribute
Casts the concept to Attribute
.
Attribute
attribute.as_attribute()
get_boolean
get_boolean() -> bool
Returns a boolean
value of the value concept that this attribute holds. If the value has another type, raises an exception.
bool
attribute.get_boolean()
get_date
get_date() -> date
Returns a timezone naive date
value of the value concept that this attribute holds. If the value has another type, raises an exception.
date
attribute.get_date()
get_datetime
get_datetime() -> Datetime
Returns a timezone naive datetime
value of the value concept that this attribute holds. If the value has another type, raises an exception.
Datetime
attribute.get_datetime()
get_datetime_tz
get_datetime_tz() -> Datetime
Returns a timezone naive datetime_tz
value of the value concept that this attribute holds. If the value has another type, raises an exception.
Datetime
attribute.get_datetime_tz()
get_decimal
get_decimal() -> Decimal
Returns a decimal
value of the value concept that this attribute holds. If the value has another type, raises an exception.
Decimal
attribute.get_decimal()
get_double
get_double() -> float
Returns a double
value of the value concept that this attribute holds. If the value has another type, raises an exception.
float
attribute.get_double()
get_duration
get_duration() -> Duration
Returns a timezone naive duration
value of the value concept that this attribute holds. If the value has another type, raises an exception.
Duration
attribute.get_duration()
get_integer
get_integer() -> int
Returns a integer
value of the value concept that this attribute holds. If the value has another type, raises an exception.
int
attribute.get_integer()
get_string
get_string() -> str
Returns a string
value of the value concept that this attribute holds. If the value has another type, raises an exception.
str
attribute.get_string()
get_struct
get_struct() -> Concept.STRUCT
Returns a struct
value of the value concept that this attribute holds represented as a map from field names to values. If the value has another type, raises an exception.
Concept.STRUCT
attribute.get_struct()
get_type
get_type() -> AttributeType
Retrieves the type which this Attribute
belongs to.
AttributeType
attribute.get_type()
get_value
get_value() -> Concept.VALUE
Retrieves the value which the Attribute
instance holds.
Concept.VALUE
attribute.get_value()
Value
Supertypes:
-
Concept
as_value
as_value() -> Value
Casts the concept to Value
.
Value
value.as_value()
get
get() -> bool | int | float | Decimal | str | date | Datetime | Duration | Dict[str, Value | None]
Retrieves the value which this value concept holds.
bool | int | float | Decimal | str | date | Datetime | Duration | Dict[str, Value | None]
value.get()
get_boolean
get_boolean() -> bool
Returns a boolean
value of this value concept. If the value has another type, raises an exception.
bool
value.get_boolean()
get_date
get_date() -> date
Returns a timezone naive date
value of this value concept. If the value has another type, raises an exception.
date
value.get_date()
get_datetime
get_datetime() -> Datetime
Returns a timezone naive datetime
value of this value concept. If the value has another type, raises an exception.
Datetime
value.get_datetime()
get_datetime_tz
get_datetime_tz() -> Datetime
Returns a timezone naive datetime_tz
value of this value concept. If the value has another type, raises an exception.
Datetime
value.get_datetime_tz()
get_decimal
get_decimal() -> Decimal
Returns a decimal
value of this value concept. If the value has another type, raises an exception.
Decimal
value.get_decimal()
get_double
get_double() -> float
Returns a double
value of this value concept. If the value has another type, raises an exception.
float
value.get_double()
get_duration
get_duration() -> Duration
Returns a timezone naive duration
value of this value concept. If the value has another type, raises an exception.
Duration
value.get_duration()
get_integer
get_integer() -> int
Returns a integer
value of this value concept. If the value has another type, raises an exception.
int
value.get_integer()
get_string
get_string() -> str
Returns a string
value of this value concept. If the value has another type, raises an exception.
str
value.get_string()
get_struct
get_struct() -> Dict[str, Value | None]
Returns a struct
value of this value concept represented as a map from field names to values. If the value has another type, raises an exception.
Dict[str, Value | None]
value.get_struct()