I am trying to connect with the AWS Neptune database using gremlinpython library from the AWS Lambda function.
from gremlin_python.driver import client
query = "g.V().count()"
uri = "wss://aws-neptune-endpoint:8182/gremlin"
clientt = client.Client(uri, 'g')
response = clientt.submit(query)
if response != None:
print('Response is OK')
return response.result()
else:
print('Response is not good ')
return None
Note: AWS Lambda function is outside of Neptune DB VPC. but When we are trying the following code, we are able to connect and get results.
from __future__ import print_function # Python 2/3 compatibility
from gremlin_python.structure.graph import Graph
from gremlin_python.driver.driver_remote_connection import DriverRemoteConnection
from gremlin_python.driver import serializer
from gremlin_python.process.anonymous_traversal import traversal
graph = Graph()
remoteConn = DriverRemoteConnection('wss://aws-neptune-endpoint:8182/gremlin','g',
pool_size=1,
message_serializer=serializer.GraphSONSerializersV2d0())
g = traversal().withRemote(remoteConn)
print(g.V().hasLabel('Company'))
remoteConn.close()
Please help, Thanks in Advance