This is a setting for when you want to fetch from inside the database
Try this:
from neo4j import GraphDatabase
# Connection details
URI = "neo4j://localhost:7687" # Replace with your Neo4j server URI
USERNAME = "neo4j" # Replace with your username
PASSWORD = "password" # Replace with your password
# File path - Neo4j server needs access to this location
CSV_PATH = "file:///home/me/data/Project/shops.csv"
# Connect to the Neo4j database
driver = GraphDatabase.driver(URI, auth=(USERNAME, PASSWORD))
# Execute the query
with driver.session(database="neo4j") as session:
query = f"""
LOAD CSV WITH HEADERS FROM '{CSV_PATH}' AS row
MERGE (h:Hospital {{id: toInteger(row.shop_id), name: row.shop_name, state: row.shop_state}});
"""
result = session.run(query, {})
# Close the driver connection
driver.close()