skip to navigation
skip to content

ajgu 0.1.0

Graphe database with several backends architecture in mind

Downloads ↓

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.

 
File Type Py Version Uploaded on Size # downloads
ajgu-0.1.0.tar.gz (md5) Source 2010-09-10 15KB 300