# get_connection

> **Function** in `langchain_neo4j`

📖 [View in docs](https://reference.langchain.com/python/langchain-neo4j/checkpoint/_internal/get_connection)

Get a Neo4j driver from various connection types.

Supports:
- Direct Driver instance (passed through)
- Connection string URI (creates new driver)

## Signature

```python
get_connection(
    conn: Conn,
) -> Iterator[Driver]
```

## Description

**Example:**

>>> with get_connection("bolt://localhost:7687") as driver:
...     with driver.session() as session:
...         session.run("MATCH (n) RETURN n")

## Parameters

| Name | Type | Required | Description |
|------|------|----------|-------------|
| `conn` | `Conn` | Yes | Either a Driver instance or a connection string URI. |

---

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