Minimal LangGraph Tutorial 1: Natural Language and DB Interaction

Introduction

With a single line of Cursor, develop a LangGraph program that can interact with any database, regardless of its structure!

Preparation

  1. Download a copy of the LangGraph code, remember the location, and update to .cursorrules
  2. Prepare a .cursorrules file to store the following content
  3. Download the DB file and reference file main.py I provided, and place them in the root directory of the project
  4. Set up a conda virtual environment

The directory structure is as follows

LangGraph-SQL4/├── main.py # Reference file├── Chinook.db # Test database└── .cursorrules # Cursor IDE configuration file

Content of the .cursorrules file :

langgraph's code in /xxx/github/langgraph using conda langgraph environment when using openai, model='deepseek-chat', base_url="https://api.deepseek.com", key=sk-xxxxpip install, default using https://pypi.tuna.tsinghua.edu.cn/simple

One Line to Get It Done

Prompt:

Develop a Python program based on LangChain, using SQLDatabaseToolkit to access SQLite (Chinook.db), achieving natural language query interaction in command-line mode. Refer to @main.py using conda langgraph environment

Cursor Works Automatically:

  1. Automatically create and enter the virtual environment
  2. Automatically install dependencies
  3. Automatically transform
  4. Automatically fix errors

Done!

File link: https://749ju.notion.site/LangGraph-1-DB-16f2cce1260e80eb826cd45e44f52800?pvs=4

If you’ve read this far, join the group chat about Cursor. WeChat ID: puppy521

Minimal LangGraph Tutorial 1: Natural Language and DB Interaction

Leave a Comment