NeptuneRdfGraph#

class langchain_aws.graphs.neptune_rdf_graph.NeptuneRdfGraph(host: str, port: int = 8182, use_https: bool = True, use_iam_auth: bool = False, client: Any = None, credentials_profile_name: str | None = None, region_name: str | None = None, service: str = 'neptunedata', sign: bool = True)[source]#

Neptune wrapper for RDF graph operations.

Parameters:
  • host (str) – endpoint for the database instance

  • port (int) – port number for the database instance, default is 8182

  • use_iam_auth (bool) – boolean indicating IAM auth is enabled in Neptune cluster

  • use_https (bool) – whether to use secure connection, default is True

  • client (Any) – optional boto3 Neptune client

  • credentials_profile_name (str | None) – optional AWS profile name

  • region_name (str | None) – optional AWS region, e.g., us-west-2

  • service (str) – optional service name, default is neptunedata

  • sign (bool) – optional, whether to sign the request payload, default is True

Example


graph = NeptuneRdfGraph(

host=’<SPARQL host’>, port=<SPARQL port>

) schema = graph.get_schema()

OR graph = NeptuneRdfGraph(

host=’<SPARQL host’>, port=<SPARQL port>

) schema_elem = graph.get_schema_elements() #… change schema_elements … graph.load_schema(schema_elem)

Security note: Make sure that the database connection uses credentials

that are narrowly-scoped to only include necessary permissions. Failure to do so may result in data corruption or loss, since the calling code may attempt commands that would result in deletion, mutation of data if appropriately prompted or reading sensitive data if such data is present in the database. The best way to guard against such negative outcomes is to (as appropriate) limit the permissions granted to the credentials used with this tool.

See https://python.langchain.com/docs/security for more information.

Attributes

get_schema

Returns the schema of the graph database.

get_schema_elements

Methods

__init__(host[,Β port,Β use_https,Β ...])

get_summary()

Obtain Neptune statistical summary of classes and predicates in the graph.

load_schema(schema_elements)

Generates and sets schema from schema_elements.

query(query)

Run Neptune query.

__init__(host: str, port: int = 8182, use_https: bool = True, use_iam_auth: bool = False, client: Any = None, credentials_profile_name: str | None = None, region_name: str | None = None, service: str = 'neptunedata', sign: bool = True) β†’ None[source]#
Parameters:
  • host (str) –

  • port (int) –

  • use_https (bool) –

  • use_iam_auth (bool) –

  • client (Any) –

  • credentials_profile_name (str | None) –

  • region_name (str | None) –

  • service (str) –

  • sign (bool) –

Return type:

None

get_summary() β†’ Dict[str, Any][source]#

Obtain Neptune statistical summary of classes and predicates in the graph.

Return type:

Dict[str, Any]

load_schema(schema_elements: Dict[str, Any]) β†’ None[source]#

Generates and sets schema from schema_elements. Helpful in cases where introspected schema needs pruning.

Parameters:

schema_elements (Dict[str, Any]) –

Return type:

None

query(query: str) β†’ Dict[str, Any][source]#

Run Neptune query.

Parameters:

query (str) –

Return type:

Dict[str, Any]

Examples using NeptuneRdfGraph