{ "info": { "author": "Aaron Moffatt", "author_email": "contact@aaronmoffatt.com", "bugtrack_url": null, "classifiers": [ "Intended Audience :: Developers", "Operating System :: OS Independent", "Programming Language :: Python" ], "description": "Neo4j Python Bindings\n========================\n\n:synopsis: Access Neo4j graph database functionality from python code\n\nOnly tested with Neo4j 1.3 on OSX Snow Leopard, Python 2.6\n\n\nNotice\n------\nThis is a work in progress. Please let me know if stuff in this document fails or doesn't seem to be true.\n\nThanks much.\n\n\nInstallation\n------------\n\nInstall JCC:\n\n$ easy_install jcc\n\nDownload and unpack neo4j somewhere (http://neo4j.org/download/)\nCurrently only version 1.3 is supported\n\nSet NEO4J_HOME environment variable to this download of Neo4j:\n\n$ export NEO4J_HOME=~/downloads/neo4j-community-1.3\n\n\nEnter the Neo4py package directory:\n\n$ cd the/directory/with/this/readme\n\nBuild C++ wrappers with JCC:\n\n$ python setup.py build\n\nInstall (may require sudo-ness):\n\n$ python setup.py install\n\n\nRun some tests:\n$ python test/test_graph_core.py\n\nHopefully no errors! If there are, send me the tracebacks :)\n\n\nGetting started\n---------------\n\nSimplest way is to use the 'global' graph.\n >>> from neo4py import neo\n >>> gdb = neo.init_graph('test-graph.neo4j')\n >>> gdb.shutdown()\n\nThis global graph may be accessed from anywhere after being initialized with\n >>> gdb = neo.get_graph()\n\n\nTransactions\n------------\n\nTransactions are handled differently than in neo4j.py\n\n >>> tx, created = gdb.get_tx()\n\nIf created is True, it is the responsibility of this scope to commit the transaction when done it:\n\n >>> tx.finish(True)\t# success - commit changes to database\n >>> tx.finish(False)\t# failure - rollback changes\n\n >>> tx.success()\t\t# or .failure()\n >>> tx.finish()\t\t# it doesn't matter if True of False is passed here -- it will be ignored\n\n\nNodes, Relationships and Properties (Beginning of fun stuff)\n----------------------------------\n\n** Not all syntax is neo4j.py compatible **\n\n\nCreating a node::\t\t\t(must be within a transaction!)\n\n >>> n = gdb.node()\n\nSpecify properties for new node::\n\n >>> n = gdb.node(petals=5, color=\"Red\", height=5.5)\t\t\t#support for number or string array properties is not yet added\n\nAccessing node by id:\n\n >>> n = gdb.nodes[14]\n \n\nAccessing properties:\n\n >>> value = n['key'] # Get property value\n \n >>> n['key'] = value # Set property value\n \n >>> del n['key'] # Remove property value\n \n # Or, with a default\n >>> value = n.get('key', 'default')\n\n >>> for prop in n: do_something(prop)\n >>> for prop, value in n.iteritems(): do_someting(prop,value)\t\t# loop through node properties\n \n >>>more_props = { \"name\" : \"Jack\", \"occupation\" : \"Pilot\" }\n >>>n1.update(more_props)\n >>>n2.update(name=\"Sarah\", occupation=\"Astronaut\")\n \n\n >>> n.id\t# Node id\n \n\nCreate relationship::\n\n >>> n1.Knows(n2, since=\"A long time ago\")\n \n # Or\n >>> n1.relationships(\"Likes\")(n2, how_much=\"A lot\") \t# Usefull when the name of\n \t\t\t# relationship is stored in a variable.\n\t\t\t\t\t \t\t\t# This syntax may change though... seems obscure?\n\n\nThe creation returns a Relationship object, which has properties accessible like nodes.\n\n >>> rel = n1.Knows(n2, since=123456789)\n >>> rel['since']\n123456789\n \nAdditional attributes:\n\n >>> rel.start\t\t# start node (n1)\n >>> rel.end\t\t# end node (n2)\n \n >>> rel.type\n 'Knows'\n\n\n\nOthers functions over 'relationships' attribute are possible. Like get all,\nincoming or outgoing relationships (typed or not):\n\n >>> rels = list(n1.relationships())\n\n \n >>> rels = list(n1.relationships(\"Knows\", \"Likes\").incoming)\n \n >>> rel = n1.Knows.outgoing.single\n\n\nTraversals\n----------\n\nIn progress. Much like neo4j.py\nSee tests (neo4py/testing/graph_core.py)\n\n >>> from neo4py.core import Direction\n >>> from neo4py.traversal import Traverser, Stop, Returnable, Order\n\n class MyTraverser(Traverser):\t\t\t\t\t\t\n types = [Direction.Incoming.Knows, Direction.Undirected.Likes]\n is_stop = lambda pos: pos.node == my_node\t\t#can use a python method\t\t#### LARGELY UNTESTED ####\n\t\t\t\t\t\t\t#pos is a TraversalPosition object\n is_returnable = Returnable.ALL\t\t\t#or a java defined ReturnableEvaluator/StopEvaluator\n\t\t\t\t\t\t\t# (these are faster)\n order = Order.DEPTH_FIRST\n\n\nIndices\n-------\n\nSee tests (neo4py/testing/graph_core.py)\n\n >>> node_idx = gdb.node_indices.create(\"My node index\", fulltext=True)\t\t#create an new fulltext index\n\t\t\t\t\t\t\t\t\t\t\t#Will fail index with name already exists\n >>> node_idx = gdb.node_indices[\"My node index\"]\t\t\t#retrieve already created index\n\n >>> \"That index\" in gdb.node_indices\t\t\t\t\t#test if index exists\nFalse\n >>> \"My node index\" in gdb.node_indices\nTrue\n \n >>> rel_idx = gdb.rel_indices.create(\"Relationship index\")\t\t# works the same, but for relationships\n\n >>> node_idx['name', \"Jack\"] = n1\n >>> node_idx['name', \"Jack\"] = n500\t\t\t# two nodes indexed under 'name' => \"Jack\"\n\n >>>nodes = list(node_idx['name', 'Jack'])\t\t# Returns iterator over both nodes (exact matching using this syntax)\n\n >>>nodes = list(node_idx.simple_query('name', 'jack')\t# fulltext query by single key/value\n >>>nodes = list(node_idx.query('name:jack'))\t\t# Run lucene query (supports multiple keys)\n\nRelationship indices same, but with a couple extra options (See Neo4j Docs):\n >>> rels = list(rel_idx.simple_query('key', 'value', start_node=n1)\t\t#limit query, for efficiency (can also be end_node)\n >>> rels = list(rel_idx.query('key:value', end_node=some_other_node)\n\n\nModels, Django support, QuerySets, Aggregates\n------\n\nIn Progress", "description_content_type": null, "docs_url": null, "download_url": "UNKNOWN", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://github.com/OneSaidWho/neo4py", "keywords": "neo4j graph graphdb graphdatabase database native cpython", "license": "AGPL 3", "maintainer": null, "maintainer_email": null, "name": "neo4py", "package_url": "https://pypi.org/project/neo4py/", "platform": "UNKNOWN", "project_url": "https://pypi.org/project/neo4py/", "project_urls": { "Download": "UNKNOWN", "Homepage": "https://github.com/OneSaidWho/neo4py" }, "release_url": "https://pypi.org/project/neo4py/0.1/", "requires_dist": null, "requires_python": null, "summary": "Python bindings for Neo4j graph database", "version": "0.1" }, "last_serial": 795230, "releases": { "0.1": [ { "comment_text": "", "digests": { "md5": "5169812f67b7ed01e48e0cdd812c63a5", "sha256": "26cba1f42fb66748473f51af29428d1cd5a4a33b605bdbaa50288e654734ad1f" }, "downloads": -1, "filename": "neo4py-0.1.tar.gz", "has_sig": false, "md5_digest": "5169812f67b7ed01e48e0cdd812c63a5", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 27892, "upload_time": "2011-06-03T14:27:17", "url": "https://files.pythonhosted.org/packages/ba/9e/162831d266061a13ed250325a8af58264bf4e5b4f8de3a06f8b73792ecd2/neo4py-0.1.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "5169812f67b7ed01e48e0cdd812c63a5", "sha256": "26cba1f42fb66748473f51af29428d1cd5a4a33b605bdbaa50288e654734ad1f" }, "downloads": -1, "filename": "neo4py-0.1.tar.gz", "has_sig": false, "md5_digest": "5169812f67b7ed01e48e0cdd812c63a5", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 27892, "upload_time": "2011-06-03T14:27:17", "url": "https://files.pythonhosted.org/packages/ba/9e/162831d266061a13ed250325a8af58264bf4e5b4f8de3a06f8b73792ecd2/neo4py-0.1.tar.gz" } ] }