Skip to content

Instantly share code, notes, and snippets.

@DecisionNerd
Forked from korakot/neo4j.py
Created March 14, 2022 06:16

Revisions

  1. @korakot korakot revised this gist Sep 23, 2019. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion neo4j.py
    Original file line number Diff line number Diff line change
    @@ -1,7 +1,7 @@
    # download 3.5.8 or neo4j-enterprise-4.0.0-alpha09mr02-unix
    !curl https://neo4j.com/artifact.php?name=neo4j-community-3.5.8-unix.tar.gz -o neo4j.tar.gz
    # decompress and rename
    !tar -xf neo4j.tar.gz
    !tar -xf neo4j.tar.gz # or --strip-components=1
    !mv neo4j-community-3.5.8 nj
    # disable password, and start server
    !sed -i '/#dbms.security.auth_enabled/s/^#//g' nj/conf/neo4j.conf
  2. @korakot korakot revised this gist Sep 20, 2019. 2 changed files with 12 additions and 1 deletion.
    2 changes: 1 addition & 1 deletion neo4j.py
    Original file line number Diff line number Diff line change
    @@ -1,4 +1,4 @@
    # download
    # download 3.5.8 or neo4j-enterprise-4.0.0-alpha09mr02-unix
    !curl https://neo4j.com/artifact.php?name=neo4j-community-3.5.8-unix.tar.gz -o neo4j.tar.gz
    # decompress and rename
    !tar -xf neo4j.tar.gz
    11 changes: 11 additions & 0 deletions nj_magic.py
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,11 @@
    !pip install py2neo -q
    from py2neo import Graph
    graph = Graph("bolt://localhost:7687")

    from IPython.core.magic import register_cell_magic
    @register_cell_magic
    def nj(line, cell=None):
    return graph.run(cell or line).to_table()

    %%nj
    MATCH (n) RETURN n
  3. @korakot korakot revised this gist Sep 19, 2019. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion neo4j.py
    Original file line number Diff line number Diff line change
    @@ -4,5 +4,5 @@
    !tar -xf neo4j.tar.gz
    !mv neo4j-community-3.5.8 nj
    # disable password, and start server
    !sed -i '/dbms.security.auth_enabled/s/^#//g' nj/conf/neo4j.conf
    !sed -i '/#dbms.security.auth_enabled/s/^#//g' nj/conf/neo4j.conf
    !nj/bin/neo4j start
  4. @korakot korakot revised this gist Sep 1, 2019. 1 changed file with 1 addition and 0 deletions.
    1 change: 1 addition & 0 deletions use_magic.py
    Original file line number Diff line number Diff line change
    @@ -1,4 +1,5 @@
    !pip install -q ipython-cypher
    import cypher # for cypher.run
    %load_ext cypher
    %config CypherMagic.feedback=False

  5. @korakot korakot revised this gist Sep 1, 2019. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion use_magic.py
    Original file line number Diff line number Diff line change
    @@ -1,4 +1,4 @@
    !pip install ipython-cypher
    !pip install -q ipython-cypher
    %load_ext cypher
    %config CypherMagic.feedback=False

  6. @korakot korakot revised this gist Sep 1, 2019. 1 changed file with 2 additions and 1 deletion.
    3 changes: 2 additions & 1 deletion pyneo.py
    Original file line number Diff line number Diff line change
    @@ -4,4 +4,5 @@
    a = Node("Person", name="Alice")
    b = Node("Person", name="Bob")
    ab = Relationship(a, "KNOWS", b)
    ab #(Alice)-[:KNOWS]->(Bob)
    ab #(Alice)-[:KNOWS]->(Bob)
    # now still floating, need to add to Graph
  7. @korakot korakot revised this gist Aug 27, 2019. 1 changed file with 1 addition and 0 deletions.
    1 change: 1 addition & 0 deletions use_magic.py
    Original file line number Diff line number Diff line change
    @@ -1,4 +1,5 @@
    !pip install ipython-cypher
    %load_ext cypher
    %config CypherMagic.feedback=False

    %cypher MATCH (a)-[]-(b) RETURN a, b
  8. @korakot korakot revised this gist Aug 27, 2019. 1 changed file with 9 additions and 0 deletions.
    9 changes: 9 additions & 0 deletions use_apoc.py
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,9 @@
    # download and config
    !wget -P nj/plugins https://github.com/neo4j-contrib/neo4j-apoc-procedures/releases/download/3.5.0.4/apoc-3.5.0.4-all.jar
    !sed -i '/dbms.security.procedures.unrestricted/s/^#//g' nj/conf/neo4j.conf
    !sed -i 's/my.extensions.example,my.procedures/apoc/' nj/conf/neo4j.conf

    !nj/bin/neo4j restart

    %%cypher
    RETURN apoc.version()
  9. @korakot korakot revised this gist Aug 27, 2019. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion neo4j.py
    Original file line number Diff line number Diff line change
    @@ -2,7 +2,7 @@
    !curl https://neo4j.com/artifact.php?name=neo4j-community-3.5.8-unix.tar.gz -o neo4j.tar.gz
    # decompress and rename
    !tar -xf neo4j.tar.gz
    !mv neo4j-community-3.5. nj
    !mv neo4j-community-3.5.8 nj
    # disable password, and start server
    !sed -i '/dbms.security.auth_enabled/s/^#//g' nj/conf/neo4j.conf
    !nj/bin/neo4j start
  10. @korakot korakot renamed this gist Aug 27, 2019. 1 changed file with 0 additions and 0 deletions.
    File renamed without changes.
  11. @korakot korakot revised this gist Aug 27, 2019. 3 changed files with 14 additions and 11 deletions.
    4 changes: 4 additions & 0 deletions magic.py
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,4 @@
    !pip install ipython-cypher
    %load_ext cypher

    %cypher MATCH (a)-[]-(b) RETURN a, b
    14 changes: 3 additions & 11 deletions neo4j.py
    Original file line number Diff line number Diff line change
    @@ -1,16 +1,8 @@
    # download
    !curl https://neo4j.com/artifact.php?name=neo4j-community-3.5.1-unix.tar.gz -o neo4j.tar.gz
    !curl https://neo4j.com/artifact.php?name=neo4j-community-3.5.8-unix.tar.gz -o neo4j.tar.gz
    # decompress and rename
    !tar -xf neo4j.tar.gz
    !mv neo4j-community-3.5.1 nj
    !mv neo4j-community-3.5. nj
    # disable password, and start server
    !sed -i '/dbms.security.auth_enabled/s/^#//g' nj/conf/neo4j.conf
    !nj/bin/neo4j start

    !pip install py2neo -q
    from py2neo.data import Node, Relationship

    a = Node("Person", name="Alice")
    b = Node("Person", name="Bob")
    ab = Relationship(a, "KNOWS", b)
    ab #(Alice)-[:KNOWS]->(Bob)
    !nj/bin/neo4j start
    7 changes: 7 additions & 0 deletions pyneo.py
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,7 @@
    !pip install py2neo -q
    from py2neo.data import Node, Relationship

    a = Node("Person", name="Alice")
    b = Node("Person", name="Bob")
    ab = Relationship(a, "KNOWS", b)
    ab #(Alice)-[:KNOWS]->(Bob)
  12. @korakot korakot created this gist Jan 7, 2019.
    16 changes: 16 additions & 0 deletions neo4j.py
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,16 @@
    # download
    !curl https://neo4j.com/artifact.php?name=neo4j-community-3.5.1-unix.tar.gz -o neo4j.tar.gz
    # decompress and rename
    !tar -xf neo4j.tar.gz
    !mv neo4j-community-3.5.1 nj
    # disable password, and start server
    !sed -i '/dbms.security.auth_enabled/s/^#//g' nj/conf/neo4j.conf
    !nj/bin/neo4j start

    !pip install py2neo -q
    from py2neo.data import Node, Relationship

    a = Node("Person", name="Alice")
    b = Node("Person", name="Bob")
    ab = Relationship(a, "KNOWS", b)
    ab #(Alice)-[:KNOWS]->(Bob)