Video summary
LangGraph + SQLite | Chatbot with Database Integration | CampusX
Main summary
Key takeaways
Summary
Nitish Singh demonstrates how to add persistent conversation storage to a LangGraph chatbot using SQLite, replacing the in-memory checkpointer used in earlier tutorials.
Why Persistence Is Needed
The chatbot already supports a Streamlit interface, token streaming, and multiple conversation threads. However, its in-memory saver stores messages in RAM, so conversations disappear when the app closes or reloads. SQLite lets users reopen and continue old chats later.
Backend Changes
- Install the external
langgraph-checkpoint-sqlitepackage. - Create or connect to a SQLite database file, such as
chatbot.db, using Python’s SQLite library. The tutorial setscheck_same_thread=Falseso the connection can be used across threads. - Configure LangGraph’s SQLite checkpointer with that connection instead of the in-memory saver.
- Test persistence by sending a message, ending the run, and starting another run with the same thread ID. The chatbot can still recall earlier messages.
- Use different thread IDs to keep conversations separate. For example, the tutorial shows one thread remembering Nitish and another remembering Rahul.
Inspecting and Retrieving Threads
- The instructor opens the database in VS Code using a SQLite viewer extension to inspect saved checkpoints and messages.
- LangGraph’s checkpointer
listmethod returns checkpoints. Since each thread may have multiple checkpoints, the tutorial extracts thread IDs and uses a set to identify unique threads. - This logic is wrapped in a
retrieve_all_threadsfunction for the frontend to call.
Frontend Changes
- Update the Streamlit app’s initialization so it fetches existing thread IDs from the backend instead of starting with an empty thread list.
- The app can then display saved conversations and their message history on launch.
- Newly created conversations are added to the thread list as usual.
Result: Chats remain available after closing or refreshing the app, and users can resume them by selecting their thread.
Guide Topics Covered
- Installing and configuring the SQLite checkpointer.
- Testing message persistence across separate program runs.
- Isolating conversation histories with thread IDs.
- Viewing SQLite checkpoints in VS Code.
- Retrieving existing threads and loading them into a Streamlit UI.
Main speaker/source: Nitish Singh, presenting on the CampusX channel.
Rate this summary
Your feedback will help improve summaries.
Improve this summary
Reprocess with a stronger model when the summary feels incomplete or inaccurate.
Translate summary in another language
Ask questions to this video
Chat for follow-up questions, clarifications, and source-backed answers.