Skip to content

Latest commit

 

History

History
62 lines (38 loc) · 1.23 KB

File metadata and controls

62 lines (38 loc) · 1.23 KB

Grakn Python Client

A Python client for Grakn.

Requires Python 3.6 and Grakn 1.0.

Installation

To install the Grakn client, simply run:

$ pip install grakn

You will also need access to a Grakn database. Head here to get started with Grakn.

Quickstart

Begin by importing the client:

>>> import grakn

Now you can connect to a knowledge base:

>>> client = grakn.Client(uri='localhost:48555', keyspace='mykb')

You can write to the knowledge base:

>>> client.execute('define person sub entity;')
{}
>>> client.execute('define name sub attribute, datatype string;')
{}
>>> client.execute('define person has name;')
{}
>>> client.execute('insert $bob isa person, has name "Bob";')
[{'bob': {'id': ...}}]
>>>

Or read from it:

>>> tx.execute('match $bob isa person, has name $name; get $name;')
[{'name': {'value': 'Bob', 'id': ...}}]
...
>>>