-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: a file for connecting to the Neo4j DB was added
- Loading branch information
1 parent
8bb1eb8
commit d8c88cc
Showing
1 changed file
with
28 additions
and
0 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 |
---|---|---|
@@ -0,0 +1,28 @@ | ||
import os | ||
from neo4j import GraphDatabase | ||
from dotenv import load_dotenv | ||
load_dotenv() | ||
|
||
user = os.getenv("NEO4J_USER") | ||
protocol = os.getenv("NEO4J_PROTOCOL") | ||
password = os.getenv("NEO4J_PASSWORD") | ||
host = os.getenv("NEO4J_HOST") | ||
port = os.getenv("NEO4J_PORT") | ||
db_name = os.getenv("NEO4J_DB") | ||
|
||
neo4j_url = f"{protocol}://{host}:{port}" | ||
neo4j_auth = (user, password) | ||
|
||
driver = GraphDatabase.driver(neo4j_url, auth=neo4j_auth) | ||
with GraphDatabase.driver(neo4j_url, auth=neo4j_auth) as driver: | ||
driver.verify_connectivity() | ||
|
||
def read(cypher, database = 'neo4j'): | ||
|
||
records, summary, keys = driver.execute_query(cypher, database_= database) | ||
return records, summary, keys | ||
|
||
def write(cypher, database = 'neo4j'): | ||
|
||
records, summary, keys = driver.execute_query(cypher, database_= database) | ||
return summary |