Skip to main content

Graphe database with several backends architecture in mind

Project description

Install Ajgu

Ajgu needs Python (tested with Python 2.6), install it with python setup.py install

Kesako Ajgu

Ajgu is graphe database library for Python in Python. It’s built with the idea of using different persistence backend and currently supports python anydbm module.

API

The API is short, check out ./tests/test_nodearrow.py for more code

Currently the API only supports:
  • creating
  • deleting
  • annotating
  • retriving

Create a graphe database

>>> from ajgu.backends import AnyDbBackend
>>> from ajgu import GrapheDatabase
>>> options = {"db_home": "/var/ajgu/mydb.dbm", "flag": "c", "mode": 438 }
>>> backend = AnyDbBackend(options)
>>> graphe = GrapheDatabase(backend)

Backends takes a dictonary to setup itself, check out each backend documentation to know which options it needs.

Create a node

>>> node = graphe.create_node()

can’t be easier, see annotations :

>>> node.set_property("title", "My super duper cool title")
>>> node.set_property("content", """Lorem ipsum dolor sit amet, consectetur
                    adipiscing elit. Maecenas massa dui, facilisis aliquam
                    facilisis sed, vulputate id nibh. Suspendisse non
                    interdum elit. Etiam placerat, lacus sed tempus
                    venenatis, velit ligula cursus elit, vel blandit elit
                    erat et turpis.""")

Only String objects are accepted as key or values, plus one more restriction on keys, they should not contains colons « : ».

To get back your data use get_property

>>> node.get_property("title")
"My super duper cool title"

you can also delete the node, all arrows linked to it are deleted:

>>> node.delete()

you can ask the graphe to retrieve a specific node:

>>> n = graphe.get_node(0)

n and node are the same graphe node.

Close the database when you finished:

>>> graphe.close()

Create an arrow

If you want to create an Arrow object you need two Node object:

>>> n1 = graphe.create_node()
>>> n1.set_property("class","twit")
>>> n2 = graphe.create_node()
>>> n2.set_property("class", "article")
>>> arrow = n1.add_arrow(n2)

You can also annotate arrows:

>>> arrow.set_property("type", "inheritance")

you can delete the arrow:

>>> arrow.delete()

it won’t delete linked node so becarful.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Files for ajgu, version 0.1.0
Filename, size & hash File type Python version Upload date
ajgu-0.1.0.tar.gz (15.5 kB) View hashes Source None

Supported by

Elastic Elastic Search Pingdom Pingdom Monitoring Google Google BigQuery Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN SignalFx SignalFx Supporter DigiCert DigiCert EV certificate StatusPage StatusPage Status page