from neo4j.v1 import GraphDatabase, basic_auth
class Neo4jWriter():
def __init__(self):
config = configparser.ConfigParser()
config.read('config.ini')
user_name = config.get('neo4j credentials', 'user_name')
password = config.get('neo4j credentials', 'password')
bolt_host = config.get('neo4j credentials', 'bolt_host')
self.driver = GraphDatabase.driver(bolt_host,
auth=basic_auth( user_name, password))
def write_person(self, Person_Node):
Person_Node.full_name = Person_Node.full_name.replace("'", "")
Person_Node.full_name = Person_Node.full_name.strip()
print('Creating Person Node:' + str(Person_Node.__dict__))
with self.driver.session() as session:
with session.begin_transaction() as write_tx:
props = Person_Node.__dict__
props = ', '.join("{!s}: {!r}".format(key, val) for (key, val) in props.items())
query = 'MERGE (a:Person {' + props + "})"
write_tx.run(query)
write_tx.success = True
Last active
December 30, 2016 00:43
-
-
Save ReedJessen/28a5bc4f28fef1e6fd411eec0806b551 to your computer and use it in GitHub Desktop.
Neo4j Writer class with one example write_node method
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment