Python version of the TerminusDB client - for TerminusDB API and WOQLpy

Overview

TerminusDB Client Python

Discord online Discourse topics Follow on Twitter

Development status ⚙️

Build Status Documentation Status codecov last commit number of contributors

Python Package status 📦

PyPI version shields.io PyPI pyversions GitHub license PyPI download month

Python version of the TerminusDB client - for TerminusDB API and WOQLpy

Client Demo gif

Requirements

Release Notes and Previous Versions

TerminusDB Client v10.0 works with TerminusDB v10.0 and TerminusX. Please check RELEASE_NOTES.md to find out what has changed.

Installation

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

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

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

python -m pip install terminusdb-client[dataframe]

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

python -m pip install 'terminusdb-client[dataframe]'

  • Install from source:

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

Usage

Python client

Connect to a server

Connect to local host

from terminusdb_client import WOQLClient

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

Connect to TerminusX

check documentation for TerminusX about how to add the API token to the environment variable

from terminusdb_client import WOQLClient

team="MyTeam"
client = WOQLClient(f"https://dashboard.terminusdb.com/{team}/")
client.connect(team="MyTeam", use_token=True)

Create a database

client.create_database("MyDatabase")

Create a schema

from terminusdb_client.woqlschema import WOQLSchema, DocumentTemplate, RandomKey

my_schema = WOQLSchema()

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

my_schema.commit(client)

Create and insert doucments

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

$terminusdb startproject
Please enter a project name (this will also be the database name): mydb
Please enter a 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

$terminusdb 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

terminusdb 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

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

Please check the full Documentation for more information.

Tutorials

There is a list of examples that uses the Python client in our tutorial repo. As a start, we would recommend having a look at create TerminusDB graph with Python client using Jupyter notebook

Testing

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

  2. Install all development dependencies using pipenv

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

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 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 forum or Discord server.

Community

Come visit us on our discord server or our forum. 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

Owner
TerminusDB
Build Data Products
TerminusDB
Apache Libcloud is a Python library which hides differences between different cloud provider APIs and allows you to manage different cloud resources through a unified and easy to use API

Apache Libcloud - a unified interface for the cloud Apache Libcloud is a Python library which hides differences between different cloud provider APIs

The Apache Software Foundation 1.9k Dec 25, 2022
A wrapper for SQLite and MySQL, Most of the queries wrapped into commands for ease.

Before you proceed, make sure you know Some real SQL, before looking at the code, otherwise you probably won't understand anything. Installation pip i

Refined 4 Jul 30, 2022
Prometheus instrumentation library for Python applications

Prometheus Python Client The official Python 2 and 3 client for Prometheus. Three Step Demo One: Install the client: pip install prometheus-client Tw

Prometheus 3.2k Jan 07, 2023
A Pythonic, object-oriented interface for working with MongoDB.

PyMODM MongoDB has paused the development of PyMODM. If there are any users who want to take over and maintain this project, or if you just have quest

mongodb 345 Dec 25, 2022
Tool for synchronizing clickhouse clusters

clicksync Tool for synchronizing clickhouse clusters works only with partitioned MergeTree tables can sync clusters with different node number uses in

Alexander Rumyantsev 1 Nov 30, 2021
Python PostgreSQL adapter to stream results of multi-statement queries without a server-side cursor

streampq Stream results of multi-statement PostgreSQL queries from Python without server-side cursors. Has benefits over some other Python PostgreSQL

Department for International Trade 6 Oct 31, 2022
Redis Python Client - The Python interface to the Redis key-value store.

redis-py The Python interface to the Redis key-value store. Installation | Contributing | Getting Started | Connecting To Redis Installation redis-py

Redis 11k Jan 08, 2023
Py2neo is a client library and toolkit for working with Neo4j from within Python

Py2neo Py2neo is a client library and toolkit for working with Neo4j from within Python applications. The library supports both Bolt and HTTP and prov

py2neo.org 1.2k Jan 02, 2023
asyncio compatible driver for elasticsearch

asyncio client library for elasticsearch aioes is a asyncio compatible library for working with Elasticsearch The project is abandoned aioes is not su

97 Sep 05, 2022
PyMongo - the Python driver for MongoDB

PyMongo Info: See the mongo site for more information. See GitHub for the latest source. Documentation: Available at pymongo.readthedocs.io Author: Mi

mongodb 3.7k Jan 08, 2023
MySQL database connector for Python (with Python 3 support)

mysqlclient This project is a fork of MySQLdb1. This project adds Python 3 support and fixed many bugs. PyPI: https://pypi.org/project/mysqlclient/ Gi

PyMySQL 2.2k Dec 25, 2022
MySQL Operator for Kubernetes

MySQL Operator for Kubernetes The MYSQL Operator for Kubernetes is an Operator for Kubernetes managing MySQL InnoDB Cluster setups inside a Kubernetes

MySQL 462 Dec 24, 2022
Databank is an easy-to-use Python library for making raw SQL queries in a multi-threaded environment.

Databank Databank is an easy-to-use Python library for making raw SQL queries in a multi-threaded environment. No ORM, no frills. Thread-safe. Only ra

snapADDY GmbH 4 Apr 04, 2022
DataStax Python Driver for Apache Cassandra

DataStax Driver for Apache Cassandra A modern, feature-rich and highly-tunable Python client library for Apache Cassandra (2.1+) and DataStax Enterpri

DataStax 1.3k Dec 25, 2022
Example Python codes that works with MySQL and Excel files (.xlsx)

Python x MySQL x Excel by Zinglecode Example Python codes that do the processes between MySQL database and Excel spreadsheet files. YouTube videos MyS

Potchara Puttawanchai 1 Feb 07, 2022
Simple Python demo app that connects to an Oracle DB.

Cloud Foundry Sample Python Application Connecting to Oracle Simple Python demo app that connects to an Oracle DB. The app is based on the example pro

Daniel Buchko 1 Jan 10, 2022
TileDB-Py is a Python interface to the TileDB Storage Engine.

TileDB-Py TileDB-Py is a Python interface to the TileDB Storage Engine. Quick Links Installation Build Instructions TileDB Documentation Python API re

TileDB, Inc. 149 Nov 28, 2022
db.py is an easier way to interact with your databases

db.py What is it Databases Supported Features Quickstart - Installation - Demo How To Contributing TODO What is it? db.py is an easier way to interact

yhat 1.2k Jan 03, 2023
Google Sheets Python API v4

pygsheets - Google Spreadsheets Python API v4 A simple, intuitive library for google sheets which gets your work done. Features: Open, create, delete

Nithin Murali 1.4k Dec 31, 2022
A CRUD and REST api with mongodb atlas.

Movies_api A CRUD and REST api with mongodb atlas. Setup First import all the python dependencies in your virtual environment or globally by the follo

Pratyush Kongalla 0 Nov 09, 2022