# Neo4jGraph

> **Class** in `langchain_community`

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

Neo4j database wrapper for various graph operations.

Parameters:
url (Optional[str]): The URL of the Neo4j database server.
username (Optional[str]): The username for database authentication.
password (Optional[str]): The password for database authentication.
database (str): The name of the database to connect to. Default is 'neo4j'.
timeout (Optional[float]): The timeout for transactions in seconds.
        Useful for terminating long-running queries.
        By default, there is no timeout set.
sanitize (bool): 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 is False.
refresh_schema (bool): A flag whether to refresh schema information
        at initialization. Default is True.
enhanced_schema (bool): A flag whether to scan the database for
        example values and use them in the graph schema. Default is False.
driver_config (Dict): Configuration passed to Neo4j Driver.

*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.

## Signature

```python
Neo4jGraph(
    self,
    url: Optional[str] = None,
    username: Optional[str] = None,
    password: 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,
)
```

## Extends

- `GraphStore`

## Constructors

```python
__init__(
    self,
    url: Optional[str] = None,
    username: Optional[str] = None,
    password: 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,
) -> None
```

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


## Properties

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

## Methods

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

## ⚠️ Deprecated

Deprecated since version 0.3.8.

---

[View source on GitHub](https://github.com/langchain-ai/langchain-community/blob/a6a6079511ac8a5c1293337f88096b8641562e77/libs/community/langchain_community/graphs/neo4j_graph.py#L325)