# -*- coding: utf-8 -*- """ Created on Wed Jan 24 12:59:58 2024 @author: CHEO001 - Dev: dev-neo4j-cluster.dev.theorchard.io - QA: qa-neo4j-cluster.theorchard.io - Prod: prod-neo4j-cluster.theorchard.io """ from neo4j import GraphDatabase from sqlalchemy import create_engine import os from dotenv import load_dotenv # pip install neo4j # pip install sqlalchemy-neo4j load_dotenv() hostlist = {'dev':'dev-neo4j-cluster.dev.theorchard.io:7687' ,'qa':'qa-neo4j-cluster.theorchard.io:7687' ,'prod':'prod-neo4j-cluster.theorchard.io:7687'} username = 'wcheong' password = {'dev':os.getenv('NEO4JDEVPW') ,'qa':os.getenv('NEO4JQAPW') ,'prod':os.getenv('NEO4JPRODPW')} # URI examples: "neo4j://localhost", "neo4j+s://xxx.databases.neo4j.io" def connectivitycheck(env): URI = "neo4j+s://{}".format(hostlist[env]) AUTH = (username, password[env]) with GraphDatabase.driver(URI, auth=AUTH) as driver: driver.verify_connectivity() def getDriver(env): URI = "neo4j+s://{}".format(hostlist[env]) AUTH = (username, password[env]) driver = GraphDatabase.driver(URI, auth=AUTH) return driver def getEngine(host, user, password): engine = create_engine("neo4j+s:///?Server={host}&Port=7687&User={username}&Password={password}".format( host = hostlist['dev'], username=username, password=password['dev'])) return engine