スキップしてコンテンツを表示

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年前1543ビュー

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年前

ログインしていません。 ログイン 回答を投稿する。

優れた回答とは、質問に明確に答え、建設的なフィードバックを提供し、質問者の専門分野におけるスキルの向上を促すものです。

関連するコンテンツ