Saving to Disk
SQLite checkpointer.
The in memory saver forgets everything when the program stops. Real apps restart all the time. A database checkpointer keeps conversations, and paused approvals, safe across restarts. SQLite is the easiest one to start with.

- Memory forgets on restart
- Apps restart often
- Save to a database
Surviving a restart
The make graph function builds the visit counter with a SQLite saver, pointing at a file. We build it once, and visit. Then we build a brand new graph object, as if the program had restarted, and visit again on the same thread. Run it. The count continues from the file, so the second graph sees two visits.
import operator, sqlite3
from typing import Annotated, TypedDict
from langgraph.checkpoint.sqlite import SqliteSaver
from langgraph.graph import StateGraph, START
class State(TypedDict):
visits: Annotated[int, operator.add]
def make_graph():
saver = SqliteSaver(sqlite3.connect("shop.db", check_same_thread=False))
b = StateGraph(State); b.add_node("visit", lambda s: {"visits": 1}); b.add_edge(START, "visit")
return b.compile(checkpointer=saver)
config = {"configurable": {"thread_id": "sam"}}
print("before restart:", make_graph().invoke({}, config)["visits"])
print("after restart: ", make_graph().invoke({}, config)["visits"])before restart: 1 after restart: 2
Checkpointers
There's a checkpointer for every stage. In memory, for tests, and learning. SQLite, for small apps on one machine. And Postgres, for production, with many servers sharing the same conversations. They all work the same way.
| Checkpointer | Use for |
|---|---|
| InMemorySaver | tests, learning |
| SqliteSaver | small apps, one machine |
| PostgresSaver | production, many servers |
Summary
A SQLite checkpointer saves state to a file, so conversations and approvals survive restarts. Postgres is the production choice. Next, serving a graph as a web API.
Key takeaways- SqliteSaver
- Survives restarts
- Postgres in production