Passer au contenu

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?

demandé il y a 3 ans1,5 k vues

1 réponse
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

répondu il y a 3 ans

Vous n'êtes pas connecté. Se connecter pour publier une réponse.

Une bonne réponse répond clairement à la question, contient des commentaires constructifs et encourage le développement professionnel de la personne qui pose la question.