# Neo4jGraph

> **Class** in `langchain_neo4j`

📖 [View in docs](https://reference.langchain.com/python/langchain-neo4j/graphs/neo4j_graph/Neo4jGraph)

Neo4j database wrapper for various graph operations.

!!! warning "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://docs.langchain.com/oss/python/security-policy for more information.

## Signature

```python
Neo4jGraph(
    self,
    url: Optional[str] = None,
    username: Optional[str] = None,
    password: Optional[str] = None,
    token: Optional[str] = None,
    database: Optional[str] = None,
    timeout: Optional[float] = None,
    sanitize: bool = False,
    refresh_schema: bool = True,
    *,
    driver_config: Optional[Dict] = None,
    enhanced_schema: bool = False,
    user_agent: str = 'LangChain-Graph',
)
```

## Parameters

| Name | Type | Required | Description |
|------|------|----------|-------------|
| `url` | `Optional[str]` | No | The URL of the Neo4j database server. (default: `None`) |
| `username` | `Optional[str]` | No | The username for database authentication. (default: `None`) |
| `password` | `Optional[str]` | No | The password for database authentication. (default: `None`) |
| `token` | `Optional[str]` | No | The authentication token for database authentication. (default: `None`) |
| `database` | `Optional[str]` | No | The name of the database to connect to. Default is `'neo4j'`. (default: `None`) |
| `timeout` | `Optional[float]` | No | The timeout for transactions in seconds. Useful for terminating long-running queries.  !!! note      By default, there is no timeout set. (default: `None`) |
| `sanitize` | `bool` | No | A flag to indicate whether to remove lists with more than 128 elements from results. Useful for removing embedding-like properties from database responses. (default: `False`) |
| `refresh_schema` | `bool` | No | A flag whether to refresh schema information at initialization. (default: `True`) |
| `driver_config` | `Optional[Dict]` | No | Configuration passed to Neo4j Driver. (default: `None`) |
| `enhanced_schema` | `bool` | No | A flag whether to scan the database for example values and use them in the graph schema. (default: `False`) |

## Extends

- `GraphStore`

## Constructors

```python
__init__(
    self,
    url: Optional[str] = None,
    username: Optional[str] = None,
    password: Optional[str] = None,
    token: Optional[str] = None,
    database: Optional[str] = None,
    timeout: Optional[float] = None,
    sanitize: bool = False,
    refresh_schema: bool = True,
    *,
    driver_config: Optional[Dict] = None,
    enhanced_schema: bool = False,
    user_agent: str = 'LangChain-Graph',
) -> None
```

| Name | Type |
|------|------|
| `url` | `Optional[str]` |
| `username` | `Optional[str]` |
| `password` | `Optional[str]` |
| `token` | `Optional[str]` |
| `database` | `Optional[str]` |
| `timeout` | `Optional[float]` |
| `sanitize` | `bool` |
| `refresh_schema` | `bool` |
| `driver_config` | `Optional[Dict]` |
| `enhanced_schema` | `bool` |
| `user_agent` | `str` |


## Properties

- `timeout`
- `sanitize`
- `schema`
- `structured_schema`
- `get_schema`
- `get_structured_schema`

## Methods

- [`query()`](https://reference.langchain.com/python/langchain-neo4j/graphs/neo4j_graph/Neo4jGraph/query)
- [`refresh_schema()`](https://reference.langchain.com/python/langchain-neo4j/graphs/neo4j_graph/Neo4jGraph/refresh_schema)
- [`add_graph_documents()`](https://reference.langchain.com/python/langchain-neo4j/graphs/neo4j_graph/Neo4jGraph/add_graph_documents)
- [`close()`](https://reference.langchain.com/python/langchain-neo4j/graphs/neo4j_graph/Neo4jGraph/close)

---

[View source on GitHub](https://github.com/langchain-ai/langchain-neo4j/blob/9bfd947b3ce63ca58fe27c059f9db6c3cc90cf78/libs/neo4j/langchain_neo4j/graphs/neo4j_graph.py#L76)