跳至内容

Neptune: Python OpenCypher client

0

I’m able to successfully connect to my Neptune instance with the code here: https://docs.aws.amazon.com/neptune/latest/userguide/iam-auth-connecting-python.html Both Gremlin and OpenCypher queries work.

However, when using this code - https://docs.aws.amazon.com/neptune/latest/userguide/access-graph-opencypher-bolt.html#access-graph-opencypher-bolt-python-iam-auth – I am unsuccessful. Error: neo4j.exceptions.DatabaseError: {code: "BoltProtocol.unexpectedException"} {message: "Unexpected server exception 'Internal Server Error'"}

I added the following lines at the end: URL="bolt://xxxyyy.us-east-1.neptune.amazonaws.com:8182"

access_key = os.getenv('AWS_ACCESS_KEY_ID', '') secret_key = os.getenv('AWS_SECRET_ACCESS_KEY', '') region = os.getenv('SERVICE_REGION', '') session_token = os.getenv('AWS_SESSION_TOKEN', '')

creds = SimpleNamespace(access_key=access_key, secret_key=secret_key, token=session_token, region=region)

authToken = NeptuneAuthToken(creds, region, URL) driver = GraphDatabase.driver(URL, auth=authToken, encrypted=True) session = driver.session() session.run("match (c:Customer) return c.mid as mid limit 1")

What am I doing wrong?

已提问 3 年前1542 查看次数

1 回答
0

The best way to handle fetching credentials is to let boto3 fetch them. It will walk the list of credential providers until it finds them in environment variables, via associated role, AWS CLI profile,etc.:

URL="bolt://<neptune_endpoint>:<neptune_port>"

session = Session()
creds = session.get_credentials()
region = '<region>'

authToken = NeptuneAuthToken(creds, region, URL) 

driver = GraphDatabase.driver(URL, auth=authToken, encrypted=True) 
drs = driver.session()

res = drs.run("match (a:Artist) return a.name as name limit 1")
for rec in res:
  print(rec)
driver.close()
AWS

已回答 3 年前

您未登录。 登录 发布回答。

一个好的回答可以清楚地解答问题和提供建设性反馈,并能促进提问者的职业发展。