{"id":72379,"date":"2026-02-05T14:06:52","date_gmt":"2026-02-05T06:06:52","guid":{"rendered":"https:\/\/www.wsisp.com\/helps\/72379.html"},"modified":"2026-02-05T14:06:52","modified_gmt":"2026-02-05T06:06:52","slug":"langchain%e5%ae%9e%e6%88%9812%ef%bc%9alangchain%e4%b8%ad%e7%9a%84%e6%96%b0%e5%9e%8bchain%e4%b9%8bcreate_sql_query_chain","status":"publish","type":"post","link":"https:\/\/www.wsisp.com\/helps\/72379.html","title":{"rendered":"(LangChain\u5b9e\u621812)\uff1aLangChain\u4e2d\u7684\u65b0\u578bChain\u4e4bcreate_sql_query_chain"},"content":{"rendered":"<h2>LangChain\u4e2d\u7684\u65b0\u578bChain\u4e4bcreate_sql_query_chain<\/h2>\n<p>\u5728\u6570\u636e\u5e93\u64cd\u4f5c\u4e2d&#xff0c;SQL\u67e5\u8be2\u662f\u6838\u5fc3\u6280\u80fd&#xff0c;\u4f46\u5bf9\u4e8e\u975e\u6280\u672f\u4eba\u5458\u6765\u8bf4&#xff0c;SQL\u8bed\u6cd5\u5f80\u5f80\u662f\u4e2a\u95e8\u69db\u3002\u4eca\u5929\u6211\u4eec\u6765\u63a2\u7d22LangChain\u4e2d\u7684\u4e00\u4e2a\u5f3a\u5927\u5de5\u5177\u2014\u2014create_sql_query_chain&#xff0c;\u5b83\u80fd\u5c06\u81ea\u7136\u8bed\u8a00\u8f6c\u6362\u4e3aSQL\u67e5\u8be2\u8bed\u53e5&#xff0c;\u8ba9\u4e0d\u61c2SQL\u7684\u4eba\u4e5f\u80fd\u8f7b\u677e\u64cd\u4f5c\u6570\u636e\u5e93\u3002<\/p>\n<h3>\u4e00\u3001\u73af\u5883\u51c6\u5907\u4e0e\u5bfc\u5165<\/h3>\n<p>\u9996\u5148\u770b\u4ee3\u7801\u7684\u5bfc\u5165\u90e8\u5206&#xff1a;<\/p>\n<p><span class=\"token keyword\">import<\/span> os<br \/>\n<span class=\"token keyword\">from<\/span> dotenv <span class=\"token keyword\">import<\/span> load_dotenv<br \/>\n<span class=\"token keyword\">from<\/span> langchain_classic<span class=\"token punctuation\">.<\/span>chains<span class=\"token punctuation\">.<\/span>sql_database<span class=\"token punctuation\">.<\/span>query <span class=\"token keyword\">import<\/span> create_sql_query_chain<br \/>\n<span class=\"token keyword\">from<\/span> langchain_community<span class=\"token punctuation\">.<\/span>utilities <span class=\"token keyword\">import<\/span> SQLDatabase<br \/>\n<span class=\"token keyword\">from<\/span> langchain_openai <span class=\"token keyword\">import<\/span> ChatOpenAI<\/p>\n<ul>\n<li>os&#xff1a;Python\u6807\u51c6\u5e93&#xff0c;\u7528\u4e8e\u8bfb\u53d6\u73af\u5883\u53d8\u91cf<\/li>\n<li>dotenv&#xff1a;\u7ba1\u7406.env\u6587\u4ef6\u4e2d\u7684\u73af\u5883\u53d8\u91cf<\/li>\n<li>create_sql_query_chain&#xff1a;\u6211\u4eec\u4eca\u5929\u8981\u8bb2\u7684\u6838\u5fc3\u529f\u80fd&#xff0c;\u521b\u5efaSQL\u67e5\u8be2\u94fe<\/li>\n<li>SQLDatabase&#xff1a;LangChain\u7684\u6570\u636e\u5e93\u5de5\u5177\u7c7b<\/li>\n<li>ChatOpenAI&#xff1a;OpenAI\u517c\u5bb9\u7684\u804a\u5929\u6a21\u578b\u63a5\u53e3<\/li>\n<\/ul>\n<h3>\u4e8c\u3001\u73af\u5883\u914d\u7f6e<\/h3>\n<p><span class=\"token comment\"># \u52a0\u8f7denv\u73af\u5883\u53d8\u91cf<\/span><br \/>\nload_dotenv<span class=\"token punctuation\">(<\/span><span class=\"token punctuation\">)<\/span><\/p>\n<p>\u8fd9\u884c\u4ee3\u7801\u4ece.env\u6587\u4ef6\u52a0\u8f7d\u73af\u5883\u53d8\u91cf&#xff0c;\u901a\u5e38\u5305\u542b&#xff1a;<\/p>\n<p>OPENAI_BASE_URL<span class=\"token operator\">&#061;<\/span>https<span class=\"token punctuation\">:<\/span><span class=\"token operator\">\/\/<\/span>api<span class=\"token punctuation\">.<\/span>deepseek<span class=\"token punctuation\">.<\/span>com<br \/>\nOPENAI_API_KEY<span class=\"token operator\">&#061;<\/span>your_api_key_here<\/p>\n<h3>\u4e09\u3001\u521d\u59cb\u5316\u5927\u8bed\u8a00\u6a21\u578b<\/h3>\n<p><span class=\"token comment\"># \u6784\u5efa\u6a21\u578b<\/span><br \/>\nllm <span class=\"token operator\">&#061;<\/span> ChatOpenAI<span class=\"token punctuation\">(<\/span><br \/>\n    model<span class=\"token operator\">&#061;<\/span><span class=\"token string\">&#034;deepseek-chat&#034;<\/span><span class=\"token punctuation\">,<\/span><br \/>\n    base_url<span class=\"token operator\">&#061;<\/span>os<span class=\"token punctuation\">.<\/span>getenv<span class=\"token punctuation\">(<\/span><span class=\"token string\">&#039;OPENAI_BASE_URL&#039;<\/span><span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">,<\/span><br \/>\n    api_key<span class=\"token operator\">&#061;<\/span>os<span class=\"token punctuation\">.<\/span>getenv<span class=\"token punctuation\">(<\/span><span class=\"token string\">&#039;OPENAI_API_KEY&#039;<\/span><span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">,<\/span><br \/>\n<span class=\"token punctuation\">)<\/span><\/p>\n<p>\u8fd9\u91cc\u521b\u5efa\u4e86\u4e00\u4e2aChatOpenAI\u5b9e\u4f8b&#xff0c;\u4f46\u91cd\u70b9\u5728\u4e8e&#xff1a;<\/p>\n<ul>\n<li>model&#061;&#034;deepseek-chat&#034;&#xff1a;\u4f7f\u7528\u7684\u662fDeepSeek\u6a21\u578b<\/li>\n<li>base_url&#xff1a;\u6307\u5b9a\u4e86DeepSeek\u7684API\u5730\u5740<\/li>\n<li>\u8fd9\u6837\u914d\u7f6e\u53ef\u4ee5\u8ba9LangChain\u7684OpenAI\u63a5\u53e3\u517c\u5bb9\u5176\u4ed6OpenAI API\u517c\u5bb9\u7684\u670d\u52a1<\/li>\n<\/ul>\n<h3>\u56db\u3001\u6570\u636e\u5e93\u8fde\u63a5\u914d\u7f6e<\/h3>\n<p><span class=\"token comment\"># \u6784\u9020mysql\u6570\u636e\u6e90<\/span><br \/>\ndb <span class=\"token operator\">&#061;<\/span> SQLDatabase<span class=\"token punctuation\">.<\/span>from_uri<span class=\"token punctuation\">(<\/span><span class=\"token string-interpolation\"><span class=\"token string\">f&#034;mysql&#043;pymysql:\/\/root:123456&#064;192.168.1.10:3306\/test_db&#034;<\/span><\/span><span class=\"token punctuation\">)<\/span><\/p>\n<p>\u6570\u636e\u5e93\u8fde\u63a5\u5b57\u7b26\u4e32\u7684\u683c\u5f0f\u4e3a&#xff1a;<\/p>\n<p>\u6570\u636e\u5e93\u7c7b\u578b&#043;\u9a71\u52a8:\/\/\u7528\u6237\u540d:\u5bc6\u7801&#064;\u4e3b\u673a\u5730\u5740:\u7aef\u53e3\/\u6570\u636e\u5e93\u540d<\/p>\n<h3>\u4e94\u3001\u521b\u5efaSQL\u67e5\u8be2\u94fe<\/h3>\n<p><span class=\"token comment\"># \u521b\u5efacreate_sql_query_chain\u5b9e\u4f8b<\/span><br \/>\nchain <span class=\"token operator\">&#061;<\/span> create_sql_query_chain<span class=\"token punctuation\">(<\/span>llm<span class=\"token punctuation\">,<\/span> db<span class=\"token punctuation\">)<\/span><\/p>\n<p>\u8fd9\u662f\u6700\u6838\u5fc3\u7684\u4e00\u6b65&#xff01;create_sql_query_chain\u51fd\u6570&#xff1a;<\/p>\n<li>\n<p>\u63a5\u6536\u4e24\u4e2a\u53c2\u6570&#xff1a;\u5927\u8bed\u8a00\u6a21\u578b\u5b9e\u4f8b\u548c\u6570\u636e\u5e93\u8fde\u63a5<\/p>\n<\/li>\n<li>\n<p>\u5185\u90e8\u5de5\u4f5c\u539f\u7406&#xff1a;<\/p>\n<ul>\n<li>\u81ea\u52a8\u83b7\u53d6\u6570\u636e\u5e93\u7684\u5143\u6570\u636e&#xff08;\u8868\u7ed3\u6784\u3001\u5b57\u6bb5\u4fe1\u606f&#xff09;<\/li>\n<li>\u5c06\u6570\u636e\u5e93\u7ed3\u6784\u4fe1\u606f\u5d4c\u5165\u5230\u63d0\u793a\u8bcd\u4e2d<\/li>\n<li>\u8bad\u7ec3\u6a21\u578b\u7406\u89e3\u5982\u4f55\u5c06\u81ea\u7136\u8bed\u8a00\u8f6c\u6362\u4e3aSQL<\/li>\n<\/ul>\n<\/li>\n<h3>\u516d\u3001\u6267\u884c\u67e5\u8be2<\/h3>\n<h4>\u57fa\u7840\u67e5\u8be2\u65b9\u5f0f&#xff1a;<\/h4>\n<p><span class=\"token comment\"># \u6267\u884c\u7ed3\u679c<\/span><br \/>\nresponse <span class=\"token operator\">&#061;<\/span> chain<span class=\"token punctuation\">.<\/span>invoke<span class=\"token punctuation\">(<\/span><span class=\"token punctuation\">{<\/span><span class=\"token string\">&#034;question&#034;<\/span><span class=\"token punctuation\">:<\/span> <span class=\"token string\">&#034;\u6570\u636e\u8868sys_user\u6709\u591a\u5c11\u7528\u6237&#034;<\/span><span class=\"token punctuation\">}<\/span><span class=\"token punctuation\">)<\/span><\/p>\n<p>invoke\u65b9\u6cd5\u63a5\u53d7\u4e00\u4e2a\u5b57\u5178&#xff0c;\u5176\u4e2dquestion\u952e\u5305\u542b\u7528\u6237\u7684\u81ea\u7136\u8bed\u8a00\u95ee\u9898\u3002<\/p>\n<h4>\u6307\u5b9a\u8868\u67e5\u8be2\u65b9\u5f0f&#xff1a;<\/h4>\n<p><span class=\"token comment\"># \u53ef\u4ee5\u6307\u5b9a\u4f7f\u7528\u7684\u591a\u5f20\u8868<\/span><br \/>\nresponse <span class=\"token operator\">&#061;<\/span> chain<span class=\"token punctuation\">.<\/span>invoke<span class=\"token punctuation\">(<\/span><span class=\"token punctuation\">{<\/span><br \/>\n    <span class=\"token string\">&#034;question&#034;<\/span><span class=\"token punctuation\">:<\/span> <span class=\"token string\">&#034;\u6570\u636e\u8868sys_user\u6709\u591a\u5c11\u7528\u6237&#034;<\/span><span class=\"token punctuation\">,<\/span><br \/>\n    <span class=\"token string\">&#034;table_names_to_use&#034;<\/span><span class=\"token punctuation\">:<\/span> <span class=\"token punctuation\">[<\/span><span class=\"token string\">&#034;sys_user&#034;<\/span><span class=\"token punctuation\">]<\/span><br \/>\n<span class=\"token punctuation\">}<\/span><span class=\"token punctuation\">)<\/span><\/p>\n<p>table_names_to_use\u53c2\u6570\u7684\u4f5c\u7528&#xff1a;<\/p>\n<ul>\n<li>\u9650\u5236\u6a21\u578b\u53ea\u8003\u8651\u6307\u5b9a\u7684\u8868<\/li>\n<li>\u63d0\u9ad8\u67e5\u8be2\u51c6\u786e\u6027<\/li>\n<li>\u907f\u514d\u6a21\u578b\u9009\u62e9\u4e0d\u76f8\u5173\u7684\u8868<\/li>\n<\/ul>\n<h3>\u4e03\u3001\u7ed3\u679c\u8f93\u51fa\u4e0e\u5206\u6790<\/h3>\n<p><span class=\"token keyword\">import<\/span> os<br \/>\n<span class=\"token keyword\">from<\/span> dotenv <span class=\"token keyword\">import<\/span> load_dotenv<br \/>\n<span class=\"token keyword\">from<\/span> langchain_classic<span class=\"token punctuation\">.<\/span>chains<span class=\"token punctuation\">.<\/span>sql_database<span class=\"token punctuation\">.<\/span>query <span class=\"token keyword\">import<\/span> create_sql_query_chain<br \/>\n<span class=\"token keyword\">from<\/span> langchain_community<span class=\"token punctuation\">.<\/span>utilities <span class=\"token keyword\">import<\/span> SQLDatabase<br \/>\n<span class=\"token keyword\">from<\/span> langchain_openai <span class=\"token keyword\">import<\/span> ChatOpenAI<\/p>\n<p><span class=\"token comment\"># \u52a0\u8f7denv\u73af\u5883\u53d8\u91cf<\/span><br \/>\nload_dotenv<span class=\"token punctuation\">(<\/span><span class=\"token punctuation\">)<\/span><\/p>\n<p><span class=\"token comment\"># \u6784\u5efa\u6a21\u578b<\/span><br \/>\nllm <span class=\"token operator\">&#061;<\/span> ChatOpenAI<span class=\"token punctuation\">(<\/span><br \/>\n    model<span class=\"token operator\">&#061;<\/span><span class=\"token string\">&#034;deepseek-chat&#034;<\/span><span class=\"token punctuation\">,<\/span><br \/>\n    base_url<span class=\"token operator\">&#061;<\/span>os<span class=\"token punctuation\">.<\/span>getenv<span class=\"token punctuation\">(<\/span><span class=\"token string\">&#039;OPENAI_BASE_URL&#039;<\/span><span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">,<\/span><br \/>\n    api_key<span class=\"token operator\">&#061;<\/span>os<span class=\"token punctuation\">.<\/span>getenv<span class=\"token punctuation\">(<\/span><span class=\"token string\">&#039;OPENAI_API_KEY&#039;<\/span><span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">,<\/span><br \/>\n<span class=\"token punctuation\">)<\/span><\/p>\n<p><span class=\"token comment\"># \u6784\u9020mysql\u6570\u636e\u6e90<\/span><br \/>\ndb <span class=\"token operator\">&#061;<\/span> SQLDatabase<span class=\"token punctuation\">.<\/span>from_uri<span class=\"token punctuation\">(<\/span><span class=\"token string-interpolation\"><span class=\"token string\">f&#034;mysql&#043;pymysql:\/\/root:123456&#064;192.168.1.12:3306\/test_db&#034;<\/span><\/span><span class=\"token punctuation\">)<\/span><\/p>\n<p><span class=\"token comment\"># \u521b\u5efacreate_sql_query_chain\u5b9e\u4f8b<\/span><br \/>\nchain <span class=\"token operator\">&#061;<\/span> create_sql_query_chain<span class=\"token punctuation\">(<\/span>llm<span class=\"token punctuation\">,<\/span> db<span class=\"token punctuation\">)<\/span><\/p>\n<p><span class=\"token comment\"># \u6267\u884c\u7ed3\u679c<\/span><br \/>\nresponse <span class=\"token operator\">&#061;<\/span> chain<span class=\"token punctuation\">.<\/span>invoke<span class=\"token punctuation\">(<\/span><span class=\"token punctuation\">{<\/span><span class=\"token string\">&#034;question&#034;<\/span><span class=\"token punctuation\">:<\/span> <span class=\"token string\">&#034;\u6570\u636e\u8868sys_user\u6709\u591a\u5c11\u7528\u6237&#034;<\/span><span class=\"token punctuation\">}<\/span><span class=\"token punctuation\">)<\/span><\/p>\n<p><span class=\"token comment\"># \u53ef\u4ee5\u6307\u5b9a\u4f7f\u7528\u7684\u591a\u5f20\u8868<\/span><br \/>\n<span class=\"token comment\"># response &#061; chain.invoke({&#034;question&#034;: &#034;\u6570\u636e\u8868sys_user\u6709\u591a\u5c11\u7528\u6237&#034;,<\/span><br \/>\n<span class=\"token comment\">#                         &#034;table_names_to_use&#034;:[&#034;sys_user&#034;]})<\/span><\/p>\n<p><span class=\"token comment\"># \u7ed3\u679c:# SQLQuery: SELECT COUNT(*) AS &#096;user_count&#096; FROM &#096;sys_user&#096;<\/span><br \/>\n<span class=\"token keyword\">print<\/span><span class=\"token punctuation\">(<\/span>response<span class=\"token punctuation\">)<\/span><\/p>\n<p>\u8fd0\u884c\u540e\u4f1a\u5f97\u5230\u7c7b\u4f3c\u8fd9\u6837\u7684\u8f93\u51fa&#xff1a;<\/p>\n<p>SELECT COUNT(*) AS user_count FROM sys_user<\/p>\n","protected":false},"excerpt":{"rendered":"<p>LangChain\u4e2d\u7684\u65b0\u578bChain\u4e4bcreate_sql_query_chain<br \/>\n\u5728\u6570\u636e\u5e93\u64cd\u4f5c\u4e2d&#xff0c;SQL\u67e5\u8be2\u662f\u6838\u5fc3\u6280\u80fd&#xff0c;\u4f46\u5bf9\u4e8e\u975e\u6280\u672f\u4eba\u5458\u6765\u8bf4&#xff0c;SQL\u8bed\u6cd5\u5f80\u5f80\u662f\u4e2a\u95e8\u69db\u3002\u4eca\u5929\u6211\u4eec\u6765\u63a2\u7d22LangChain\u4e2d\u7684\u4e00\u4e2a\u5f3a\u5927\u5de5\u5177\u2014\u2014create_sql_query_chain&#xff0c;\u5b83\u80fd\u5c06\u81ea\u7136\u8bed\u8a00\u8f6c\u6362\u4e3aSQL\u67e5\u8be2\u8bed\u53e5&#xff0c;\u8ba9\u4e0d\u61c2SQL\u7684\u4eba\u4e5f\u80fd\u8f7b\u677e\u64cd\u4f5c\u6570\u636e\u5e93\u3002<br \/>\n\u4e00\u3001\u73af\u5883\u51c6\u5907\u4e0e\u5bfc\u5165<br \/>\n\u9996\u5148\u770b\u4ee3\u7801\u7684\u5bfc\u5165\u90e8\u5206&#xff1a;<br \/>\nimport<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[997,768,50,100],"topic":[],"class_list":["post-72379","post","type-post","status-publish","format-standard","hentry","category-server","tag-langchain","tag-sql","tag-50","tag-100"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v20.3 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>(LangChain\u5b9e\u621812)\uff1aLangChain\u4e2d\u7684\u65b0\u578bChain\u4e4bcreate_sql_query_chain - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.wsisp.com\/helps\/72379.html\" \/>\n<meta property=\"og:locale\" content=\"zh_CN\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"(LangChain\u5b9e\u621812)\uff1aLangChain\u4e2d\u7684\u65b0\u578bChain\u4e4bcreate_sql_query_chain - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\" \/>\n<meta property=\"og:description\" content=\"LangChain\u4e2d\u7684\u65b0\u578bChain\u4e4bcreate_sql_query_chain \u5728\u6570\u636e\u5e93\u64cd\u4f5c\u4e2d&#xff0c;SQL\u67e5\u8be2\u662f\u6838\u5fc3\u6280\u80fd&#xff0c;\u4f46\u5bf9\u4e8e\u975e\u6280\u672f\u4eba\u5458\u6765\u8bf4&#xff0c;SQL\u8bed\u6cd5\u5f80\u5f80\u662f\u4e2a\u95e8\u69db\u3002\u4eca\u5929\u6211\u4eec\u6765\u63a2\u7d22LangChain\u4e2d\u7684\u4e00\u4e2a\u5f3a\u5927\u5de5\u5177\u2014\u2014create_sql_query_chain&#xff0c;\u5b83\u80fd\u5c06\u81ea\u7136\u8bed\u8a00\u8f6c\u6362\u4e3aSQL\u67e5\u8be2\u8bed\u53e5&#xff0c;\u8ba9\u4e0d\u61c2SQL\u7684\u4eba\u4e5f\u80fd\u8f7b\u677e\u64cd\u4f5c\u6570\u636e\u5e93\u3002 \u4e00\u3001\u73af\u5883\u51c6\u5907\u4e0e\u5bfc\u5165 \u9996\u5148\u770b\u4ee3\u7801\u7684\u5bfc\u5165\u90e8\u5206&#xff1a; import\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.wsisp.com\/helps\/72379.html\" \/>\n<meta property=\"og:site_name\" content=\"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\" \/>\n<meta property=\"article:published_time\" content=\"2026-02-05T06:06:52+00:00\" \/>\n<meta name=\"author\" content=\"admin\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"\u4f5c\u8005\" \/>\n\t<meta name=\"twitter:data1\" content=\"admin\" \/>\n\t<meta name=\"twitter:label2\" content=\"\u9884\u8ba1\u9605\u8bfb\u65f6\u95f4\" \/>\n\t<meta name=\"twitter:data2\" content=\"2 \u5206\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/72379.html\",\"url\":\"https:\/\/www.wsisp.com\/helps\/72379.html\",\"name\":\"(LangChain\u5b9e\u621812)\uff1aLangChain\u4e2d\u7684\u65b0\u578bChain\u4e4bcreate_sql_query_chain - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\",\"isPartOf\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/#website\"},\"datePublished\":\"2026-02-05T06:06:52+00:00\",\"dateModified\":\"2026-02-05T06:06:52+00:00\",\"author\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41\"},\"breadcrumb\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/72379.html#breadcrumb\"},\"inLanguage\":\"zh-Hans\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.wsisp.com\/helps\/72379.html\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/72379.html#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"\u9996\u9875\",\"item\":\"https:\/\/www.wsisp.com\/helps\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"(LangChain\u5b9e\u621812)\uff1aLangChain\u4e2d\u7684\u65b0\u578bChain\u4e4bcreate_sql_query_chain\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/#website\",\"url\":\"https:\/\/www.wsisp.com\/helps\/\",\"name\":\"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\",\"description\":\"\u9999\u6e2f\u670d\u52a1\u5668_\u9999\u6e2f\u4e91\u670d\u52a1\u5668\u8d44\u8baf_\u670d\u52a1\u5668\u5e2e\u52a9\u6587\u6863_\u670d\u52a1\u5668\u6559\u7a0b\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/www.wsisp.com\/helps\/?s={search_term_string}\"},\"query-input\":\"required name=search_term_string\"}],\"inLanguage\":\"zh-Hans\"},{\"@type\":\"Person\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41\",\"name\":\"admin\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"zh-Hans\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery\",\"contentUrl\":\"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery\",\"caption\":\"admin\"},\"sameAs\":[\"http:\/\/wp.wsisp.com\"],\"url\":\"https:\/\/www.wsisp.com\/helps\/author\/admin\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"(LangChain\u5b9e\u621812)\uff1aLangChain\u4e2d\u7684\u65b0\u578bChain\u4e4bcreate_sql_query_chain - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.wsisp.com\/helps\/72379.html","og_locale":"zh_CN","og_type":"article","og_title":"(LangChain\u5b9e\u621812)\uff1aLangChain\u4e2d\u7684\u65b0\u578bChain\u4e4bcreate_sql_query_chain - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","og_description":"LangChain\u4e2d\u7684\u65b0\u578bChain\u4e4bcreate_sql_query_chain \u5728\u6570\u636e\u5e93\u64cd\u4f5c\u4e2d&#xff0c;SQL\u67e5\u8be2\u662f\u6838\u5fc3\u6280\u80fd&#xff0c;\u4f46\u5bf9\u4e8e\u975e\u6280\u672f\u4eba\u5458\u6765\u8bf4&#xff0c;SQL\u8bed\u6cd5\u5f80\u5f80\u662f\u4e2a\u95e8\u69db\u3002\u4eca\u5929\u6211\u4eec\u6765\u63a2\u7d22LangChain\u4e2d\u7684\u4e00\u4e2a\u5f3a\u5927\u5de5\u5177\u2014\u2014create_sql_query_chain&#xff0c;\u5b83\u80fd\u5c06\u81ea\u7136\u8bed\u8a00\u8f6c\u6362\u4e3aSQL\u67e5\u8be2\u8bed\u53e5&#xff0c;\u8ba9\u4e0d\u61c2SQL\u7684\u4eba\u4e5f\u80fd\u8f7b\u677e\u64cd\u4f5c\u6570\u636e\u5e93\u3002 \u4e00\u3001\u73af\u5883\u51c6\u5907\u4e0e\u5bfc\u5165 \u9996\u5148\u770b\u4ee3\u7801\u7684\u5bfc\u5165\u90e8\u5206&#xff1a; import","og_url":"https:\/\/www.wsisp.com\/helps\/72379.html","og_site_name":"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","article_published_time":"2026-02-05T06:06:52+00:00","author":"admin","twitter_card":"summary_large_image","twitter_misc":{"\u4f5c\u8005":"admin","\u9884\u8ba1\u9605\u8bfb\u65f6\u95f4":"2 \u5206"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/www.wsisp.com\/helps\/72379.html","url":"https:\/\/www.wsisp.com\/helps\/72379.html","name":"(LangChain\u5b9e\u621812)\uff1aLangChain\u4e2d\u7684\u65b0\u578bChain\u4e4bcreate_sql_query_chain - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","isPartOf":{"@id":"https:\/\/www.wsisp.com\/helps\/#website"},"datePublished":"2026-02-05T06:06:52+00:00","dateModified":"2026-02-05T06:06:52+00:00","author":{"@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41"},"breadcrumb":{"@id":"https:\/\/www.wsisp.com\/helps\/72379.html#breadcrumb"},"inLanguage":"zh-Hans","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.wsisp.com\/helps\/72379.html"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/www.wsisp.com\/helps\/72379.html#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"\u9996\u9875","item":"https:\/\/www.wsisp.com\/helps"},{"@type":"ListItem","position":2,"name":"(LangChain\u5b9e\u621812)\uff1aLangChain\u4e2d\u7684\u65b0\u578bChain\u4e4bcreate_sql_query_chain"}]},{"@type":"WebSite","@id":"https:\/\/www.wsisp.com\/helps\/#website","url":"https:\/\/www.wsisp.com\/helps\/","name":"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","description":"\u9999\u6e2f\u670d\u52a1\u5668_\u9999\u6e2f\u4e91\u670d\u52a1\u5668\u8d44\u8baf_\u670d\u52a1\u5668\u5e2e\u52a9\u6587\u6863_\u670d\u52a1\u5668\u6559\u7a0b","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.wsisp.com\/helps\/?s={search_term_string}"},"query-input":"required name=search_term_string"}],"inLanguage":"zh-Hans"},{"@type":"Person","@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41","name":"admin","image":{"@type":"ImageObject","inLanguage":"zh-Hans","@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/image\/","url":"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery","contentUrl":"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery","caption":"admin"},"sameAs":["http:\/\/wp.wsisp.com"],"url":"https:\/\/www.wsisp.com\/helps\/author\/admin"}]}},"_links":{"self":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts\/72379","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/comments?post=72379"}],"version-history":[{"count":0,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts\/72379\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/media?parent=72379"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/categories?post=72379"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/tags?post=72379"},{"taxonomy":"topic","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/topic?post=72379"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}