mgbam commited on
Commit
e338885
·
verified ·
1 Parent(s): eccb85d

Update utils/neo4j_queries.py

Browse files
Files changed (1) hide show
  1. utils/neo4j_queries.py +18 -0
utils/neo4j_queries.py CHANGED
@@ -0,0 +1,18 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # genesis/utils/neo4j_utils.py
2
+ from neo4j import GraphDatabase
3
+ import os
4
+
5
+ NEO4J_URI = os.getenv("NEO4J_URI")
6
+ NEO4J_USER = os.getenv("NEO4J_USER", "neo4j")
7
+ NEO4J_PASSWORD = os.getenv("NEO4J_PASSWORD")
8
+
9
+ driver = GraphDatabase.driver(NEO4J_URI, auth=(NEO4J_USER, NEO4J_PASSWORD))
10
+
11
+ def run_query(query: str, params: dict = None):
12
+ """Run a Cypher query against the Neo4j database."""
13
+ with driver.session() as session:
14
+ result = session.run(query, params or {})
15
+ return [record.data() for record in result]
16
+
17
+ def close_driver():
18
+ driver.close()