-
Notifications
You must be signed in to change notification settings - Fork 209
Description
Environment:
docker部署的tugraph/tugraph-runtime-centos7:latest
使用项目中提供的python代码例子,增加一个创建图的一行,在提前创建下,没有报错,但是对于没有提前创建的图表会找不到希望新建的图表,我的问题是如何用 Neo4j 官方 Python 驱动(neo4j 包)通过 bolt 协议,在 TuGraph 实例上创建一个新的图(Graph)?
`from neo4j import GraphDatabase
URI = "bolt://x.x.x.x:7687"
AUTH = ("admin", "73@TuGraph")
DATABASE = "test"
with GraphDatabase.driver(URI, auth=AUTH) as client:
client.session().run(f"CALL db.createGraph('{DATABASE}')")
session = client.session(database=DATABASE)
session.run("CALL db.dropDB()")
session.run("CALL db.createVertexLabel('person', 'id' , 'id', 'INT32', false, 'name', 'STRING', false)")
session.run("CALL db.createEdgeLabel('is_friend','[["person","person"]]')")
session.run("create (n1:person {name:'jack',id:1}), (n2:person {name:'lucy',id:2})")
session.run("match (n1:person {id:1}), (n2:person {id:2}) create (n1)-[r:is_friend]->(n2)")
ret = session.run("match (n)-[r]->(m) return n,r,m")
for item in ret.data():
print(item)
`