How do you install the Neo4j and create a new driver instance?
Install the driver
Complete the shell command to install the Neo4j Python Driver.
sh
pip install #select:neo4j
-
❏ graphdatabase
-
❏ graphdb
-
✓ neo4j
-
❏ neo4j-python-driver
Hint
You can find the library name on PyPI.
Solution
The correct answer is neo4j
.
shell
pip install neo4j
Create a new driver instance
Great work! With the driver installed, you can now create a new driver instance.
Complete the code below to create a new driver instance.
python
from neo4j import GraphDatabase
NEO4J_URI = "neo4j://localhost:7687"
NEO4J_USERNAME = "neo4j"
NEO4J_PASSWORD = "letmein"
driver = GraphDatabase.#select:driver(
NEO4J_URI,
auth=(NEO4J_USERNAME, NEO4J_PASSWORD)
)
-
❏ connect(
-
✓ driver(
-
❏ GraphDatabase(
-
❏ new_driver(
Hint
What is the name of the object used to connect a Neo4j instance?
Solution
The method to create a new connection is GraphDatabase.driver()
.
shell
driver = GraphDatabase.driver(
NEO4J_URI,
auth=(NEO4J_USERNAME, NEO4J_PASSWORD)
)
Summary
You can now install the neo4j
library and connect to Neo4j by creating a new driver instance.
In the next lesson, you will learn how to execute your first Cypher query.