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?

posta 5 mesi fa375 visualizzazioni
1 Risposta
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
con risposta 5 mesi fa

Accesso non effettuato. Accedi per postare una risposta.

Una buona risposta soddisfa chiaramente la domanda, fornisce un feedback costruttivo e incoraggia la crescita professionale del richiedente.

Linee guida per rispondere alle domande