LoginSignup
0
0

More than 3 years have passed since last update.

neo4jでsandbox その15

Posted at

概要

neo4jでsandboxやってみた。
pythonでneo4j sandboxを叩いて、gistのデータを投入してみた。

nodeを投入。


from neo4j import GraphDatabase, basic_auth

driver = GraphDatabase.driver("bolt://18.233.67.98:32829", auth=basic_auth("neo4j", "convenience-patient-function"))
session = driver.session()
cypher_query = '''
LOAD CSV WITH HEADERS FROM "https://gist.github.com/ohisama/20ff770bfda7d9dafbb1fc0e259aeb9f/raw/938b739af1e2627a66a3ee781d0c46559ca61663/covid0.csv" AS line
CREATE (:Person {id:line.id, tiku:line.tiku, tosi:line.tosi, sex:line.sex, date:line.date})
'''
results = session.run(cypher_query, parameters = {})
for record in results:
    print(record)



linkを投入。


from neo4j import GraphDatabase, basic_auth

driver = GraphDatabase.driver("bolt://18.233.67.98:32829", auth=basic_auth("neo4j", "convenience-patient-function"))
session = driver.session()
cypher_query = '''
LOAD CSV WITH HEADERS FROM "https://gist.github.com/ohisama/20ff770bfda7d9dafbb1fc0e259aeb9f/raw/938b739af1e2627a66a3ee781d0c46559ca61663/covid1.csv" AS line
MATCH (a:Person {id:line.a}), (b:Person {id:line.b})
CREATE (a)-[:CONNCT]->(b)
'''
results = session.run(cypher_query, parameters = {})
for record in results:
    print(record)



以上。

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0