ajgu

Graphe database with several backends architecture in mind
Download

ajgu Ranking & Summary

Advertisement

  • Rating:
  • License:
  • AGPL
  • Publisher Name:
  • Amirouche Boubekki
  • Publisher web site:
  • http://bitbucket.org/abki/

ajgu Tags


ajgu Description

Graphe database with several backends architecture in mind 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.APIThe API is short, check out ./tests/test_nodearrow.py for more codeCurrently the API only supports: * creating * deleting * annotating * retrivingCreate 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 arrowIf 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. Requirements: · Python


ajgu Related Software