Officially out now: The TypeDB 3.0 Roadmap >>

Lesson 11: Manipulating stateful objects

In this lesson, we’ll learn to use the TypeDB driver APIs to retrieve and operate on stateful data objects. We’ll begin by seeing how we can retrieve data instances and schema types from the database as stateful objects using Get queries or by programmatic retrieval. Then we’ll see how to operate on those objects, including how to programmatically create and modify data instances.

The examples and exercises in this lesson feature the official TypeDB Python driver.

  • You should complete Lesson 6 before starting this lesson.

  • You should complete Lesson 8 before starting this lesson.

Lesson contents

Learn how to retrieve stateful objects using queries.

Learn how to retrieve stateful objects using API calls.

Learn how to modify data via retrieved stateful objects.

Necessary imports

The following classes must be imported in order to use the Python driver in any codebase.

from typedb.driver import TypeDB, SessionType, TransactionType
from typedb.api.connection.credential import TypeDBCredential

Additionally, we’ll be using the following classes for type hints in this lesson. They should be imported to run the examples and exercises featured.

from typing import Iterator
from typedb.api.connection.transaction import TypeDBTransaction
from typedb.api.answer.concept_map import ConceptMap
from typedb.api.concept.thing.entity import Entity
from typedb.api.concept.thing.relation import Relation
from typedb.api.concept.thing.attribute import Attribute
from typedb.api.concept.thing.thing import Thing
from typedb.api.concept.type.entity_type import EntityType
from typedb.api.concept.type.relation_type import RelationType
from typedb.api.concept.type.attribute_type import AttributeType
from typedb.api.concept.type.role_type import RoleType

Using other driver languages

Official drivers are also available for other languages. All official drivers offer very similar APIs, so it is recommended to use the Python driver while following this course, as the skills learned will be easily transferable to the other drivers.