Skip to content

aelred/grakn-python

Repository files navigation

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='http://localhost:4567', 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': {'type': {'label': 'person', '@id': '/kb/mykb/type/person'}, 'id': ...}}]

Or read from it:

>>> resp = client.execute('match $bob isa person, has name $name; get $name;')
[{'name': {'type': {'label': 'name', '@id': '/kb/mykb/type/name'}, 'value': 'Bob', 'id': ...}}]

About

Grakn Python Driver

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published