gpt4 book ai didi

python - 如何使用python(neo4j模块)远程访问在azure上运行的neo4j社区容器?

转载 作者:行者123 更新时间:2023-12-03 03:40:16 27 4
gpt4 key购买 nike

有一个neo4j社区版容器运行在azure上,我是由dns提供的

http://[remote-address]:7687

如果我使用代理(来自github的px)(也推荐office)进行curl,我能够成功获取bolt_routing、transaction、bolt_direct、neo4j_version、neo4j_edition,

通过网络浏览器的 7474 端口,我还可以通过添加远程数据库连接到数据库,并与 Neo4j 桌面相同。

但是当我使用 python neo4j 驱动程序时,无法解析地址 [远程地址]:7687

import neo4j,sys
link = "bolt://" + sys.argv[1]
print(f"Trying to connect to: {link}")

def exp():
try:
x = neo4j.GraphDatabase.driver(link, auth=("neo4j", "my_pswd"))

print(x.verify_connectivity())
except Exception as e:
print(e)

那么,如何连接到 Azure 上托管的容器?

更新:

我尝试连接正在运行的 azure 实例的 IP,但是

Couldn't connect to [IP-address]:7687 (resolved to ('[IP-address]:7687',)):

Failed to establish connection to ResolvedIPv4Address(('[IP-address]', 7687)) (reason [WinError 10060] A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond)

通过网络和neo4j浏览器连接完全没问题,只是不能通过python脚本连接。!!

最佳答案

我会推荐 neo4j Aura。它是一个完全托管的云服务,可以轻松地连接到数据库。它还有一个免费套餐可供尝试。请参阅示例脚本以连接到它:

https://neo4j.com/cloud/aura/

import neo4j,sys
link = "bolt://" + sys.argv[1]
print(f"Trying to connect to: {link}")
#format of uri is <9999>.databases.neo4j.io

def exp():
try:
x = neo4j.GraphDatabase.driver(link, auth=("neo4j", "my_pswd"))

print(x.verify_connectivity())
except Exception as e:
print(e)

关于python - 如何使用python(neo4j模块)远程访问在azure上运行的neo4j社区容器?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/71508617/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com