Skip to content

Instantly share code, notes, and snippets.

@DecisionNerd
Forked from korakot/neo4j.py
Created March 14, 2022 06:16
Show Gist options
  • Save DecisionNerd/efe2ffa1dd69b4c83e359f8c25b72236 to your computer and use it in GitHub Desktop.
Save DecisionNerd/efe2ffa1dd69b4c83e359f8c25b72236 to your computer and use it in GitHub Desktop.
Using Neo4j in Colab
# download
!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.8 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)
# now still floating, need to add to Graph
# 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()
!pip install -q ipython-cypher
import cypher # for cypher.run
%load_ext cypher
%config CypherMagic.feedback=False
%cypher MATCH (a)-[]-(b) RETURN a, b
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment