繁体   English   中英

为什么我收到错误消息:无法获取数据库的路由表

[英]Why I'm getting the error message: Unable to get a routing table for database

我正在尝试在 neo4j 中构建简单的数据库并检查节点是否存在。

我写了一个简单的代码:

def find_and_return_person(tx, person_name):
    query = (
        "MATCH (p:Person) "
        "WHERE p.name = $person_name "
        "RETURN p.name AS name"
    )
    result = tx.run(query, person_name=person_name)
    return [record["name"] for record in result]

if __name__ == "__main__":
    scheme = "neo4j"
    host_name = "localhost"
    port = 7687
    url = "{scheme}://{host_name}:{port}".format(scheme=scheme, host_name=host_name, port=port)
    user = "neo4j"
    password = "s3cr3t"
    driver = GraphDatabase.driver(url, auth=(user, password))
    session = driver.session(database="foo")
    result = session.read_transaction(find_and_return_person, "Alice")

但我收到错误:

neo4j.exceptions.ClientError: {code: Neo.ClientError.Database.DatabaseNotFound} {message: Unable to get a routing table for database 'foo' because this database does not exist}

怎么了 ? (我创建了一个名为“foo”的新会话)那么它缺少什么?

除非您想使用“system”或“neo4j”数据库,否则您需要在尝试使用之前创建一个数据库

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM