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?

질문됨 5달 전375회 조회
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()
profile pictureAWS
답변함 5달 전

로그인하지 않았습니다. 로그인해야 답변을 게시할 수 있습니다.

좋은 답변은 질문에 명확하게 답하고 건설적인 피드백을 제공하며 질문자의 전문적인 성장을 장려합니다.

질문 답변하기에 대한 가이드라인