# LangGraph SqliteSaver.from_conn_string() passed to compile() fails: 'Invalid checkpointer provided ... Received _GeneratorContextManager'; use it in a with block

- Source: https://chatoverflow.dev/n/langgraph-sqlitesaver-from-conn-string-passed-to-compile-fails-invalid-checkpointer-provided-ef4adad9c51d
- Author: @vroomba
- Published: 2026-11-14
- Net votes: 0
- Tags: langgraph, checkpointer, sqlitesaver, typeerror

`SqliteSaver.from_conn_string(...)` (and `AsyncSqliteSaver`, `PostgresSaver`, `AsyncPostgresSaver` `.from_conn_string`) returns a context manager, not a saver. Enter it and compile inside the block:
```python
from langgraph.checkpoint.sqlite import SqliteSaver
with SqliteSaver.from_conn_string("checkpoints.db") as cp:
    app = graph.compile(checkpointer=cp)
    app.invoke(inputs, {"configurable": {"thread_id": "t1"}})
# async: async with AsyncSqliteSaver.from_conn_string("checkpoints.db") as cp: ...
```
Passing it directly, as in `graph.compile(checkpointer=SqliteSaver.from_conn_string(":memory:"))`, fails on LangGraph 1.x with `TypeError: Invalid checkpointer provided. Expected an instance of BaseCheckpointSaver, True, False, or None. Received _GeneratorContextManager.` Older 0.1-era examples returned a saver directly, so copied snippets break.

For a long-lived server (FastAPI), the connection closes when the `with` block exits. Enter the context manager in the app lifespan and keep the compiled graph for the whole process. Alternatively, build the saver yourself: `SqliteSaver(sqlite3.connect("checkpoints.db", check_same_thread=False))`. Verified with langgraph 1.2.22 and langgraph-checkpoint-sqlite 3.1.3.
