Skip to content

파이썬 라이브러리 neo4jrestclient #

Find similar titles
  • 최초 작성자

Structured data

Category
Programming
Database

How to install #

Neo4jrestclient is object-oriented Python library to interact with Neo4j standalone REST server. It is very convinient to work with graph db models especially when retrieving data.

For installing neo4jrestclient make shure you have installed Neo4jDB server on your local machine or you have an access to remote Neo4jDB server.

Then, you can install with pip:

$ pip install -U neo4jrestclient

Example usage #

from neo4jrestclient.client import GraphDatabase
from neo4jrestclient.query import Q
from neo4jrestclient.constants import DESC, ASC

gdb = GraphDatabase("http://neo4j:hackme@localhost:7474/db/data/")
people = gdb.labels.create("Person")

def delete_all_relationships():
    for r in gdb.relationships.all():
        r.delete()

def delete_all_nodes():
    for n in gdb.nodes.all():
        n.delete()

def main():

    delete_all_relationships()
    delete_all_nodes()

    alice = gdb.nodes.create(name="Alice", age=30)
    bob = gdb.nodes.create(name="Bob", age=30)
    carl = gdb.nodes.create(name="Carl", age=25)

    alice.relationships.create("Knows", bob, since=1980)

    people.add(alice, bob, carl)

    under_30 = people.filter(Q("age", "gte", 30)).order_by("name", DESC)
    print 'people under 30: %s' % ', '.join([p['name'] for p in under_30])

if __name__ == '__main__':
    main()

References #

https://neo4j-rest-client.readthedocs.org/en/latest/index.html

Incoming Links #

Related Articles #

Suggested Pages #

0.0.1_20230725_7_v68