Skip to content

Instantly share code, notes, and snippets.

@chrismaddalena
Created April 15, 2019 13:58
Show Gist options
  • Save chrismaddalena/869566a45f87f8ec5d56c1d6bf544f07 to your computer and use it in GitHub Desktop.
Save chrismaddalena/869566a45f87f8ec5d56c1d6bf544f07 to your computer and use it in GitHub Desktop.
from neo4j import GraphDatabase
def setup_database_conn():
"""Function to setup the database connection to the Neo4j project containing the BloodHound data."""
try:
database_uri = 'bolt://localhost:7687'
database_user = 'neo4j'
database_pass = 'bloodhound'
print("[!] Attempting to connect to your Neo4j project using {}:{} @ {}.".format(database_user, database_pass, database_uri))
neo4j_driver = GraphDatabase.driver(database_uri, auth=(database_user, database_pass))
print("[+] Success!")
return neo4j_driver
except:
neo4j_driver = None
print("[X] Database connection failed!")
exit()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment