Update src/graph/graph_loader.py
Browse files
src/graph/graph_loader.py
CHANGED
|
@@ -6,6 +6,7 @@ from dotenv import load_dotenv
|
|
| 6 |
load_dotenv()
|
| 7 |
|
| 8 |
class KnowledgeGraphPersister:
|
|
|
|
| 9 |
def __init__(self):
|
| 10 |
"""
|
| 11 |
Inizializza il driver Neo4j usando le variabili d'ambiente per sicurezza.
|
|
@@ -18,14 +19,13 @@ class KnowledgeGraphPersister:
|
|
| 18 |
self.driver = GraphDatabase.driver(uri, auth=(user, password))
|
| 19 |
self.driver.verify_connectivity()
|
| 20 |
print(f"✅ Connesso a Neo4j ({uri}).")
|
| 21 |
-
|
| 22 |
# Creazione indici all'avvio (Fondamentale per la velocità dei MERGE)
|
| 23 |
self._create_constraints()
|
| 24 |
-
|
| 25 |
except Exception as e:
|
| 26 |
print(f"❌ Errore critico connessione Neo4j: {e}")
|
| 27 |
self.driver = None
|
| 28 |
|
|
|
|
| 29 |
def close(self):
|
| 30 |
if self.driver:
|
| 31 |
self.driver.close()
|
|
|
|
| 6 |
load_dotenv()
|
| 7 |
|
| 8 |
class KnowledgeGraphPersister:
|
| 9 |
+
|
| 10 |
def __init__(self):
|
| 11 |
"""
|
| 12 |
Inizializza il driver Neo4j usando le variabili d'ambiente per sicurezza.
|
|
|
|
| 19 |
self.driver = GraphDatabase.driver(uri, auth=(user, password))
|
| 20 |
self.driver.verify_connectivity()
|
| 21 |
print(f"✅ Connesso a Neo4j ({uri}).")
|
|
|
|
| 22 |
# Creazione indici all'avvio (Fondamentale per la velocità dei MERGE)
|
| 23 |
self._create_constraints()
|
|
|
|
| 24 |
except Exception as e:
|
| 25 |
print(f"❌ Errore critico connessione Neo4j: {e}")
|
| 26 |
self.driver = None
|
| 27 |
|
| 28 |
+
|
| 29 |
def close(self):
|
| 30 |
if self.driver:
|
| 31 |
self.driver.close()
|