Skip to main content

TerminusDB Python Client


Discord Reddit Twitter

release version downloads

build status documentation code coverage license

Python client for TerminusDB and TerminusCMS.

Migrating from terminusdb-client? This package was formerly known as terminusdb-client. Simply install terminusdb instead — both import terminusdb and import terminusdb_client continue to work, so no code changes are required.

TerminusDB is an open-source graph database and document store. It allows you to link JSON documents in a powerful knowledge graph all through a simple document API, with full git-for-data version control.

Requirements

Release Notes and Previous Versions

TerminusDB Client v12 works with TerminusDB v12 onwards and the DFRNT cloud service. Please check the Release Notes to find out what has changed.

Installation

  • TerminusDB Client can be downloaded from PyPI using pip: python -m pip install terminusdb

This only includes the core Python Client (Client) and WOQLQuery.

If you want to use woqlDataframe or the import and export CSV function in the Scaffolding CLI tool:

python -m pip install terminusdb[dataframe]

if you are installing from zsh you have to quote the argument like this:

python -m pip install 'terminusdb[dataframe]'

  • Install from source:

python -m pip install git+https://github.com/terminusdb/terminusdb-client-python.git

Demo

Client Demo gif

Usage

Python client

Connect to a server

Connect to local host

from terminusdb import Client

client = Client("http://127.0.0.1:6363/")
client.connect()

The previous import path from terminusdb_client import Client also continues to work.

Connect to TerminusDB in the cloud

check the documentation on the DFRNT support page about how to add your API token to the environment variable

from terminusdb import Client

team="MyTeam"
client = Client(f"https://studio.dfrnt.com/api/hosted/{team}/")
client.connect(team="MyTeam", use_token=True)

Create a database

client.create_database("MyDatabase")

Create a schema

from terminusdb.schema import Schema, DocumentTemplate, RandomKey

my_schema = Schema()

class Pet(DocumentTemplate):
    _schema = my_schema
    name: str
    species: str
    age: int
    weight: float

my_schema.commit(client)

Create and insert documents

my_dog = Pet(name="Honda", species="Huskey", age=3, weight=21.1)
my_cat = Pet(name="Tiger", species="Bengal cat", age=5, weight=4.5)
client.insert_document([my_dog, my_cat])

Get back all documents

print(list(client.get_all_documents()))
[{'@id': 'Pet/b5edacf854e34fe79c228a91e2af45fb', '@type': 'Pet', 'age': 5, 'name': 'Tiger', 'species': 'Bengal cat', 'weight': 4.5}, {'@id': 'Pet/cdbe3f6d49394b38b952ae315309256d', '@type': 'Pet', 'age': 3, 'name': 'Honda', 'species': 'Huskey', 'weight': 21.1}]

Get a specific document

print(list(client.query_document({"@type":"Pet", "age":5})))
[{'@id': 'Pet/145eb73966d14a1394f7cd5576d7d0b8', '@type': 'Pet', 'age': 5, 'name': 'Tiger', 'species': 'Bengal cat', 'weight': 4.5}]

Delete a database

client.delete_database("MyDatabase")

Scaffolding CLI tool

Scaffolding Demo gif

Start a project in the directory

$ tdbpy startproject
Please enter a project name (this will also be the database name): mydb
Please enter an endpoint location (press enter to use localhost default) [http://127.0.0.1:6363/]:
config.json and schema.py created, please customize them to start your project.

Import a CSV named grades.csv

$ tdbpy importcsv grades.csv --na=error
0it [00:00, ?it/s]
Schema object Grades created with grades.csv inserted into database.
schema.py is updated with mydb schema.
1it [00:00,  1.00it/s]
Records in grades.csv inserted as type Grades into database with Lexical ids.

Get documents with query

$ tdbpy alldocs --type Grades -q grade="B-"
[{'@id': 'Grades/Android_Electric_087-65-4321_42.0_23.0_36.0_45.0_47.0_B-', '@type': 'Grades', 'final': 47.0, 'first_name': 'Electric', 'grade': 'B-', 'last_name': 'Android', 'ssn': '087-65-4321', 'test1': 42.0, 'test2': 23.0, 'test3': 36.0, 'test4': 45.0}, {'@id': 'Grades/Elephant_Ima_456-71-9012_45.0_1.0_78.0_88.0_77.0_B-', '@type': 'Grades', 'final': 77.0, 'first_name': 'Ima', 'grade': 'B-', 'last_name': 'Elephant', 'ssn': '456-71-9012', 'test1': 45.0, 'test2': 1.0, 'test3': 78.0, 'test4': 88.0}, {'@id': 'Grades/Franklin_Benny_234-56-2890_50.0_1.0_90.0_80.0_90.0_B-', '@type': 'Grades', 'final': 90.0, 'first_name': 'Benny', 'grade': 'B-', 'last_name': 'Franklin', 'ssn': '234-56-2890', 'test1': 50.0, 'test2': 1.0, 'test3': 90.0, 'test4': 80.0}]

Delete the database

$ tdbpy deletedb
Do you want to delete 'mydb'? WARNING: This operation is non-reversible. [y/N]: y
mydb deleted.

Please check the full Documentation for more information.

Guides & Tutorials

Visit our documentation for a range of short how-to guides, how-to use the Python Client and how to use the collaboration features with the Python Client. Alternatively, undertake the Getting Started with the Python Client Tutorial Series..

Testing

  1. Clone this repository git clone https://github.com/terminusdb/terminusdb-client-python.git

  2. Install all development dependencies using poetry

$ make init
  1. (a) To run test files only
$ poetry run pytest terminusdb_client/tests
  1. (b) To run full test
$ poetry run tox -e test

Or you can run tests in poetry shell then no need to use poetry run

Documentation

Visit our TerminusDB Documentation for the full explanation of using TerminusDB.

Documentation specifically on the latest version of the Python Client can be found here.

Generating Documentation Locally using Sphinx

  1. Clone this repository git clone https://github.com/terminusdb/terminusdb-client-python.git

  2. Install all development dependencies

$ make init
  1. Change the directory to docs
$ cd docs/
  1. Build with Sphinx
$ make html

The output files are under docs/build/html, open index.html in your browser to inspect.

Report Issues

If you encounter any issues, please report them with your os and environment setup, the version that you are using and a simple reproducible case.

If you have other questions, you can ask in our community community Subreddit or Discord server.

Community

Come visit us on our discord server or our community Subreddit. We are also on Twitter

Contribute

It will be nice, if you open an issue first so that we can know what is going on, then, fork this repo and push in your ideas. Do not forget to add some test(s) of what value you adding.

Please check CONTRIBUTING.md for more information.

Licence

Apache License (Version 2.0)

Copyright (c) 2019

Release files for terminusdb 12.0.5

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for terminusdb 12.0.5
File Size Uploaded
terminusdb-12.0.5.tar.gz 209.0 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for terminusdb 12.0.5
File Interpreter ABI Platform
terminusdb-12.0.5-py3-none-any.whl Python 3 none any Details

Total release size: 466.9 kB

Release files / terminusdb-12.0.5.tar.gz

Download URL terminusdb-12.0.5.tar.gz
Size 209.0 kB
Tags Source
SHA-256 checksum
How to use checksums
82e7cda9d6d47444d79cafd6a9282420a36758d8b470adc26d54e96bc6b493cd
BLAKE2b-256 checksum
How to use checksums
f651e6550e580b4b9416d2737324b4d2e8f907d4916ce066d092cbf2c7a06f5a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.7

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Feb 26, 2026.

Transparency log

Release files / terminusdb-12.0.5-py3-none-any.whl

Download URL terminusdb-12.0.5-py3-none-any.whl
Size 258.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
abc5ca9babab811f8873d2145912a94ae8f0864657dbf77a5ba4956725f4ffa9
BLAKE2b-256 checksum
How to use checksums
69afa87bbc88f03c5e7f4e909335fb1301572c791e304a8c72785f8afc40139c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.7

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Feb 26, 2026.

Transparency log

Release history Release notifications | RSS feed

This release

12.0.5 This release

2 release files

12.0.4

2 release files

12.0.3

2 release files

12.0.1

2 release files

12.0.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page