Last active
May 11, 2024 01:27
-
-
Save korakot/328aaac51d78e589b4a176228e4bb06f to your computer and use it in GitHub Desktop.
Using Neo4j in Colab
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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 # 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 | |
!nj/bin/neo4j start |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
!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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
!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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
!pip install -q ipython-cypher | |
import cypher # for cypher.run | |
%load_ext cypher | |
%config CypherMagic.feedback=False | |
%cypher MATCH (a)-[]-(b) RETURN a, b |
The problem is that the URL is screwed up, use this code and it will work
# 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
!curl -O https://dist.neo4j.org/neo4j-community-3.5.30-unix.tar.gz neo4j.tar.gz
# decompress and rename
#!tar -xf neo4j.tar.gz # or --strip-components=1
!tar -xf neo4j-community-3.5.30-unix.tar.gz
!mv neo4j-community-3.5.30 nj
# disable password, and start server
!sed -i '/#dbms.security.auth_enabled/s/^#//g' nj/conf/neo4j.conf
!nj/bin/neo4j start
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hello!
I tried to use the above in Colad but it does not work, I get the following:
After doing:
#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 # 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
!nj/bin/neo4j start
I get:
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
0 0 0 0 0 0 0 0 --:--:-- --:--:-- --:--:-- 0
tar: This does not look like a tar archive
gzip: stdin: unexpected end of file
tar: Child returned status 1
tar: Error is not recoverable: exiting now
mv: cannot stat 'neo4j-community-3.5.8': No such file or directory
sed: can't read nj/conf/neo4j.conf: No such file or directory
/bin/bash: nj/bin/neo4j: No such file or directory
Any idea of where the problem resides, please?