-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
WIP: Have communication with Neo4j working
- Loading branch information
1 parent
e4292b3
commit 79ddea2
Showing
5 changed files
with
43 additions
and
16 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -127,3 +127,5 @@ dmypy.json | |
|
||
# Pyre type checker | ||
.pyre/ | ||
|
||
.idea |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,32 @@ | ||
# neo4j-yelp | ||
# Neo4j Yelp Dataset Solution | ||
|
||
Contains Python scripts to import and model the Yelp challenge dataset into Neo4j respectively. | ||
|
||
## Getting Started | ||
|
||
### Step 1: | ||
|
||
Download the [Neo4j Community Edition](https://neo4j.com/download-thanks/?edition=community&release=4.0.1&flavour=unix) ZIP or tarball or start the Neo4j Docker container with the `docker-compose.yml` file. | ||
|
||
If using the ZIP or tarball, extract the archive to a directory e.g. `$HOME`: | ||
``` | ||
tar -xvzf neo4j-community-4.0.1-unix.tar.gz -C ~/. | ||
``` | ||
|
||
### Step 2: | ||
|
||
If not using the Docker image, start Neo4j using the `neo4j` binary in the `neo4j-community-4.0.1/bin` file. Example: | ||
``` | ||
~/neo4j-community-4.0.1/bin/neo4j start | ||
``` | ||
Note this needs to run with Oracle Java 11 or OpenJDK 11. I recommend using [AdoptOpenJDK 11](https://adoptopenjdk.net/installation.html?variant=openjdk11&jvmVariant=hotspot) and setting $JAVA_HOME to the location of the directory e.g. `export JAVA_HOME=/home/david/Downloads/jdk-11.0.5+10`. | ||
|
||
Neo4j browser should now be running on `http://localhost:7474`. Default username and password is `neo4j` and `neo4j` respectively. | ||
|
||
### Step 3: | ||
|
||
Before running the `neo4j_yelp.py` script, make sure that you have installed all of the dependencies and edited `config.py` to contain your credentials. To download all the dependencies you can simply type: | ||
``` | ||
pip3 install -r requirements.txt --user | ||
``` | ||
|
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,5 @@ | ||
PROTO = "bolt" | ||
USER = "neo4j" | ||
PASSWORD = "bitnami" | ||
URI = "bolt://localhost:7687" | ||
PASSWORD = "MyPassword" | ||
HOSTNAME = "localhost" | ||
PORT = "7687" |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,8 @@ | ||
from neo4j import GraphDatabase | ||
from py2neo import Graph | ||
import config | ||
|
||
uri = "bolt://0.0.0.0:7687" | ||
driver = GraphDatabase.driver(uri, auth=("neo4j", "bitnami")) | ||
uri = "{}://{}:{}@{}:{}".format(config.PROTO, config.USER, config.PASSWORD, config.HOSTNAME, config.PORT) | ||
|
||
def print_friends_of(tx, name): | ||
for record in tx.run("MATCH (a:Person)-[:KNOWS]->(f) " | ||
"WHERE a.name = {name} " | ||
"RETURN f.name", name=name): | ||
print(record["f.name"]) | ||
graph = Graph(uri) | ||
|
||
with driver.session() as session: | ||
session.read_transaction(print_friends_of, "Alice") | ||
print(graph.evaluate("MATCH (tom {name: \"Tom Hanks\"}) RETURN tom")) |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1 @@ | ||
neo4j==1.7.6 | ||
neobolt==1.7.16 | ||
neotime==1.7.4 | ||
py2neo |