我使用py2neo和Neo4j v3。
我加载一些CSV文件,创建索引并进行一些匹配:
graph.run("MATCH (n) DETACH DELETE n")
graph.run("LOAD CSV WITH HEADERS FROM 'file:///Users/samshort/Work/asi/project/neo4j-flask/ch_officer.csv' AS row CREATE (n:Officer) SET n = row;")
graph.run("LOAD CSV WITH HEADERS FROM 'file:///Users/samshort/Work/asi/project/neo4j-flask/ch_company.csv' AS row CREATE (n:Company) SET n = row;")
graph.run("LOAD CSV WITH HEADERS FROM 'file:///Users/samshort/Work/asi/project/neo4j-flask/ch_company_officer.csv' AS row CREATE (n:CompanyOfficer) SET n = row;")
graph.run("CREATE INDEX ON :Officer(officer_id);")
graph.run("CREATE INDEX ON :Company(company_id);")
graph.run("MATCH (o:Officer), (co:CompanyOfficer) WHERE o.officer_id = co.officer_id CREATE (o)-[:linked]->(co);")
graph.run("MATCH (co:CompanyOfficer), (c:Company) WHERE co.company_id = c.company_id CREATE (co)-[:linked]->(c);")
然后,我在浏览器中打开Neo4j(http://localhost:7474/)并运行命令:
START n=node(*) RETURN n
然后导出图表。
我的问题:如何实现自动化?这样,当我的python脚本运行完毕时,保存结果图? (因此完全不需要在我的浏览器中打开Neo4j。)
很抱歉,如果在别处问过这个问题 - 我做了很多谷歌搜索,没有运气......
提前致谢:) 萨姆