|
| 1 | +# Introduction |
| 2 | + |
| 3 | +This set of examples assumes you have the movie database loaded |
| 4 | + |
| 5 | +See https://neo4j.com/graphgists/cypher-introduction-social-movie-database/ for details on the movie database. |
| 6 | + |
| 7 | +# Dependencies |
| 8 | + |
| 9 | +All of the dependencies listed below need to be in place before running the code. |
| 10 | + |
| 11 | + - Python virtual environment |
| 12 | + - Environment variables |
| 13 | + |
| 14 | +## Python Virtual Environment |
| 15 | + |
| 16 | + - Move to the neo4j folder |
| 17 | + - `cd <neo4j>` |
| 18 | + - Create a virtual environment |
| 19 | + - On Mac: `python3 -m venv .venv` |
| 20 | + - On Windows: `python -m venv .venv` |
| 21 | + - Activate the virtual environment |
| 22 | + - On Mac: `source .venv/bin/activate` |
| 23 | + - On Windows: `.venv\Scripts\activate` |
| 24 | + - Install dependencies |
| 25 | + - On Mac: `pip3 install -r requirements.txt` |
| 26 | + - On Windows: `pip install -r requirements.txt` |
| 27 | + - Call a specific script |
| 28 | + - On Mac: `python3 <script_name>.py` |
| 29 | + - On Windows: `python <script_name>.py` |
| 30 | + - Deactivate virtual environment |
| 31 | + - `deactivate` |
| 32 | + |
| 33 | +## Environment Variables |
| 34 | + |
| 35 | +Create a file named `.env` with the contents shown below |
| 36 | + |
| 37 | +``` |
| 38 | +NEO4J_URI=<address> |
| 39 | +NEO4J_USER=<user> |
| 40 | +NEO4J_PASSWORD=<password> |
| 41 | +``` |
| 42 | + |
| 43 | +# Example Output |
| 44 | + |
| 45 | +## simple.py |
| 46 | + |
| 47 | +```text |
| 48 | +python3 simple.py |
| 49 | +
|
| 50 | +Successfully connected to Neo4j |
| 51 | +Running a simple query: |
| 52 | +Movies that Tom Hanks acted in: |
| 53 | + - Apollo 13 |
| 54 | + - You've Got Mail |
| 55 | + - A League of Their Own |
| 56 | + - Joe Versus the Volcano |
| 57 | + - That Thing You Do |
| 58 | + - The Da Vinci Code |
| 59 | + - Cloud Atlas |
| 60 | + - Cast Away |
| 61 | + - The Green Mile |
| 62 | + - Sleepless in Seattle |
| 63 | + - The Polar Express |
| 64 | + - Charlie Wilson's War |
| 65 | +
|
| 66 | +The query `MATCH (actor:Person {name: $name})-[:ACTED_IN]->(movies) RETURN actor,movies` returned 12 records in 9 ms. |
| 67 | +``` |
0 commit comments