{"id":44379,"date":"2025-06-18T17:17:40","date_gmt":"2025-06-18T09:17:40","guid":{"rendered":"https:\/\/www.wsisp.com\/helps\/44379.html"},"modified":"2025-06-18T17:17:40","modified_gmt":"2025-06-18T09:17:40","slug":"%e5%91%8a%e5%88%ab%e5%a4%8d%e6%9d%82sql%ef%bc%81vanna%e9%97%ae%e7%ad%94%e5%bc%95%e6%93%8e%e6%9e%84%e5%bb%ba%e5%8a%a8%e6%80%81%e5%8f%af%e8%a7%86%e5%8c%96%e6%8a%a5%e8%a1%a8","status":"publish","type":"post","link":"https:\/\/www.wsisp.com\/helps\/44379.html","title":{"rendered":"\u544a\u522b\u590d\u6742SQL\uff01Vanna\u95ee\u7b54\u5f15\u64ce\u6784\u5efa\u52a8\u6001\u53ef\u89c6\u5316\u62a5\u8868"},"content":{"rendered":"<h3>\u4e00\u3001Vanna\u7b80\u4ecb<\/h3>\n<p>Vanna\u662f\u4e00\u4e2a\u5f00\u6e90\u7684\u3001\u57fa\u4e8ePython\u7684RAG&#xff08;\u68c0\u7d22\u589e\u5f3a\u751f\u6210&#xff09;\u6846\u67b6&#xff0c;\u4e13\u95e8\u7528\u4e8eSQL\u751f\u6210\u548c\u76f8\u5173\u529f\u80fd\u3002\u5b83\u80fd\u5c06\u81ea\u7136\u8bed\u8a00\u95ee\u9898\u81ea\u52a8\u8f6c\u6210SQL&#xff0c;\u5e76\u4e14\u8fd8\u80fd\u76f4\u63a5\u8dd1\u5728\u6570\u636e\u5e93\u4e0a&#xff0c;\u81ea\u52a8\u751f\u6210\u53ef\u89c6\u5316\u56fe\u8868\u3002\u5176\u4e3b\u8981\u7279\u70b9\u548c\u4f18\u52bf\u5305\u62ec&#xff1a;<\/p>\n<ul>\n<li>\u6613\u7528\u6027&#xff1a;\u5141\u8bb8\u975e\u6280\u672f\u7528\u6237\u901a\u8fc7\u81ea\u7136\u8bed\u8a00\u4e0e\u6570\u636e\u5e93\u4ea4\u4e92&#xff0c;\u65e0\u9700\u7f16\u5199\u590d\u6742\u7684SQL\u67e5\u8be2\u3002<\/li>\n<li>\u7075\u6d3b\u6027&#xff1a;\u53ef\u4ee5\u5904\u7406\u591a\u79cd\u7c7b\u578b\u7684\u6570\u636e\u5e93\u548c\u67e5\u8be2&#xff0c;\u9002\u7528\u4e8e\u4e0d\u540c\u7684\u5e94\u7528\u573a\u666f\u3002<\/li>\n<li>\u51c6\u786e\u6027&#xff1a;Vanna\u7684\u80fd\u529b\u4e0e\u63d0\u4f9b\u7684\u8bad\u7ec3\u6570\u636e\u76f8\u5173&#xff0c;\u66f4\u591a\u7684\u8bad\u7ec3\u6570\u636e\u610f\u5473\u7740\u5728\u5927\u578b\u548c\u590d\u6742\u7684\u6570\u636e\u96c6\u4e0a\u6709\u66f4\u597d\u7684\u51c6\u786e\u6027\u3002<\/li>\n<li>\u5b89\u5168\u6027&#xff1a;\u6570\u636e\u5e93\u5185\u5bb9\u4e0d\u4f1a\u76f4\u63a5\u53d1\u9001\u7ed9LLM&#xff0c;SQL\u6267\u884c\u53d1\u751f\u5728\u672c\u5730\u73af\u5883\u4e2d\u3002<\/li>\n<li>\u81ea\u6211\u5b66\u4e60&#xff1a;\u53ef\u4ee5\u9009\u62e9\u5728\u6210\u529f\u6267\u884c\u7684\u67e5\u8be2\u4e0a\u201c\u81ea\u52a8\u8bad\u7ec3\u201d&#xff0c;\u6216\u8ba9\u754c\u9762\u63d0\u793a\u7528\u6237\u5bf9\u7ed3\u679c\u63d0\u4f9b\u53cd\u9988&#xff0c;\u4f7f\u672a\u6765\u7684\u7ed3\u679c\u66f4\u52a0\u51c6\u786e\u3002<\/li>\n<\/ul>\n<h3>\u4e8c\u3001\u73af\u5883\u51c6\u5907<\/h3>\n<h4>2.1 \u5b89\u88c5Vanna\u5e93<\/h4>\n<p>\u4f7f\u7528pip\u5b89\u88c5vanna\u5e93&#xff0c;\u6839\u636e\u4e0d\u540c\u7684\u9700\u6c42\u53ef\u4ee5\u5b89\u88c5\u4e0d\u540c\u7684\u6269\u5c55&#xff0c;\u4f8b\u5982\u8fde\u63a5Chromadb\u5411\u91cf\u6570\u636e\u5e93\u3001\u4f7f\u7528ollama\u6a21\u578b\u3001\u8fde\u63a5mysql\u6570\u636e\u5e93\u7b49&#xff1a;<\/p>\n<p># \u5b89\u88c5\u57fa\u672c\u7684vanna\u5e93 pip install vanna  # \u5b89\u88c5\u5e26\u6709chromadb\u3001ollama\u3001mysql\u6269\u5c55\u7684vanna\u5e93 pip install &#039;vanna[chromadb,ollama,mysql]&#039; <\/p>\n<h4>2.2 \u5b89\u88c5\u5176\u4ed6\u4f9d\u8d56\u5e93<\/h4>\n<p>\u5982\u679c\u9700\u8981\u8fde\u63a5mysql\u6570\u636e\u5e93&#xff0c;\u9700\u8981\u5b89\u88c5mysql-connector-python&#xff1b;\u5982\u679c\u4f7f\u7528Chromadb\u4f5c\u4e3a\u5411\u91cf\u6570\u636e\u5e93&#xff0c;\u9700\u8981\u5b89\u88c5Chromadb&#xff1a;<\/p>\n<p>pip install mysql-connector-python pip install ChromaDB <\/p>\n<h3>\u4e09\u3001\u4ee3\u7801\u6848\u4f8b<\/h3>\n<h4>3.1 \u57fa\u672c\u4f7f\u7528\u793a\u4f8b<\/h4>\n<p>\u4ee5\u4e0b\u662f\u4e00\u4e2a\u7b80\u5355\u7684\u4f7f\u7528Vanna\u5c06\u81ea\u7136\u8bed\u8a00\u8f6c\u6362\u4e3aSQL\u67e5\u8be2\u5e76\u6267\u884c\u7684\u793a\u4f8b&#xff1a;<\/p>\n<p>import vanna as vn<\/p>\n<p># \u8fde\u63a5\u5230SQLite\u6570\u636e\u5e93<br \/>\nvn.connect_to_sqlite(&#039;https:\/\/vanna.ai\/Chinook.sqlite&#039;)<\/p>\n<p># \u6dfb\u52a0\u793a\u4f8b\u67e5\u8be2&#xff0c;\u7528\u4e8e\u8bad\u7ec3\u6a21\u578b\u4ee5\u63d0\u9ad8\u51c6\u786e\u6027<br \/>\nvn.add_example_query(&#034;\u663e\u793a2023\u5e74\u9500\u552e\u989d\u6700\u9ad8\u7684\u4ea7\u54c1&#034;, &#034;SELECT product FROM sales WHERE YEAR(date) &#061; 2023 ORDER BY amount DESC LIMIT 1&#034;)<\/p>\n<p># \u4f7f\u7528\u81ea\u7136\u8bed\u8a00\u751f\u6210SQL\u67e5\u8be2<br \/>\nquestion &#061; &#034;\u663e\u793a2023\u5e74\u9500\u552e\u989d\u6700\u9ad8\u7684\u4ea7\u54c1&#034;<br \/>\nsql &#061; vn.generate_sql(question)<br \/>\nprint(&#034;\u751f\u6210\u7684SQL\u67e5\u8be2:&#034;, sql)<\/p>\n<p># \u5c06\u751f\u6210\u7684SQL\u67e5\u8be2\u53d1\u9001\u5230\u6570\u636e\u5e93\u5e76\u83b7\u53d6\u7ed3\u679c<br \/>\nresults &#061; vn.execute_query(sql)<br \/>\nprint(&#034;\u67e5\u8be2\u7ed3\u679c:&#034;, results) <\/p>\n<h4>3.2 \u7ed3\u5408Streamlit\u6784\u5efa\u4ea4\u4e92\u5f0f\u5e94\u7528\u793a\u4f8b<\/h4>\n<p>Vanna\u53ef\u4ee5\u4e0eStreamlit\u7ed3\u5408&#xff0c;\u6784\u5efa\u4e00\u4e2a\u667a\u80fd\u5316\u7684\u6570\u636e\u67e5\u8be2\u5e94\u7528&#xff0c;\u8ba9\u6570\u636e\u5206\u6790\u53d8\u5f97\u66f4\u52a0\u8f7b\u677e\u548c\u9ad8\u6548\u3002\u4ee5\u4e0b\u662f\u8be6\u7ec6\u7684\u914d\u7f6e\u548c\u4ee3\u7801\u5b9e\u73b0\u6b65\u9aa4&#xff1a;<\/p>\n<h5>3.2.1 \u5b89\u88c5\u4e0e\u914d\u7f6e<\/h5>\n<p>\u9996\u5148&#xff0c;\u521b\u5efa\u4e00\u4e2a\u65b0\u7684Python\u865a\u62df\u73af\u5883&#xff0c;\u7136\u540e\u5b89\u88c5\u5fc5\u8981\u7684\u4f9d\u8d56\u5305&#xff1a;<\/p>\n<p>python3 -m venv venv source venv\/bin\/activate pip install -r requirements.txt <\/p>\n<p>\u5176\u4e2d&#xff0c;requirements.txt \u6587\u4ef6\u5e94\u8be5\u5305\u542b\u4ee5\u4e0b\u4f9d\u8d56&#xff1a;<\/p>\n<p>streamlit vanna plotly <\/p>\n<h5>3.2.2 \u914d\u7f6eVanna AI<\/h5>\n<p>\u5728 vanna_calls.py \u6587\u4ef6\u4e2d&#xff0c;\u8bbe\u7f6eVanna AI\u7684\u914d\u7f6e&#xff0c;\u5305\u62ec\u8bbe\u7f6eAPI\u5bc6\u94a5\u548c\u9009\u62e9\u5408\u9002\u7684\u6a21\u578b&#xff1a;<\/p>\n<p>import vanna as vn import streamlit as st  # \u8bbe\u7f6eVanna\u7684API\u5bc6\u94a5\u548c\u6a21\u578b<br \/>\ndef setup_vanna():<br \/>\n  vn.api_key &#061; st.secrets[&#034;vanna_api_key&#034;]<br \/>\n  vn.set_model(&#034;gpt-3.5-turbo-16k&#034;)  # \u5176\u4ed6\u914d\u7f6e&#8230;<br \/>\n  return vn <\/p>\n<h5>3.2.3 \u6784\u5efaStreamlit\u5e94\u7528<\/h5>\n<p>\u5728 app.py \u6587\u4ef6\u4e2d&#xff0c;\u521b\u5efaStreamlit\u5e94\u7528\u7684\u6838\u5fc3\u903b\u8f91&#xff0c;\u5141\u8bb8\u7528\u6237\u8f93\u5165\u81ea\u7136\u8bed\u8a00\u67e5\u8be2&#xff0c;\u7136\u540e\u751f\u6210SQL&#xff0c;\u6267\u884c\u67e5\u8be2&#xff0c;\u5e76\u5c55\u793a\u7ed3\u679c\u548c\u53ef\u89c6\u5316&#xff1a;<\/p>\n<p>import streamlit as st<br \/>\nimport vanna_calls as vc<br \/>\nimport plotly.graph_objects as go<\/p>\n<p># \u4e3b\u51fd\u6570<br \/>\ndef main():<br \/>\n    st.title(&#034;Vanna AI\u667a\u80fd\u6570\u636e\u67e5\u8be2\u52a9\u624b&#034;)<\/p>\n<p>    # \u7528\u6237\u8f93\u5165<br \/>\n    user_query &#061; st.text_input(&#034;\u8bf7\u8f93\u5165\u4f60\u7684\u6570\u636e\u67e5\u8be2\u95ee\u9898&#xff1a;&#034;)<\/p>\n<p>    if user_query:<br \/>\n        with st.spinner(&#034;\u6b63\u5728\u751f\u6210SQL&#8230;&#034;):<br \/>\n            # \u751f\u6210SQL\u67e5\u8be2<br \/>\n            sql &#061; vc.generate_sql(user_query)<br \/>\n            st.code(sql, language&#061;&#034;sql&#034;)<\/p>\n<p>        with st.spinner(&#034;\u6267\u884c\u67e5\u8be2&#8230;&#034;):<br \/>\n            # \u6267\u884c\u67e5\u8be2<br \/>\n            results &#061; vc.execute_query(sql)<br \/>\n            st.dataframe(results)<\/p>\n<p>        with st.spinner(&#034;\u751f\u6210\u53ef\u89c6\u5316&#8230;&#034;):<br \/>\n            # \u751f\u6210\u53ef\u89c6\u5316\u56fe\u8868<br \/>\n            fig &#061; vc.generate_visualization(results, user_query)<br \/>\n            st.plotly_chart(fig)<\/p>\n<p>if __name__ &#061;&#061; &#034;__main__&#034;:<br \/>\n    main() <\/p>\n<h5>3.2.4 \u5b9e\u73b0\u6838\u5fc3\u529f\u80fd<\/h5>\n<p>\u5728 vanna_calls.py \u4e2d&#xff0c;\u5b9e\u73b0\u751f\u6210SQL\u3001\u6267\u884c\u67e5\u8be2\u548c\u751f\u6210\u53ef\u89c6\u5316\u56fe\u8868\u7684\u6838\u5fc3\u529f\u80fd&#xff1a;<\/p>\n<p>mport vanna as vn<br \/>\nimport streamlit as st<br \/>\nimport plotly.graph_objects as go<br \/>\nimport pandas as pd<\/p>\n<p># \u83b7\u53d6\u6570\u636e\u5e93\u8fde\u63a5<br \/>\ndef get_database_connection():<br \/>\n    # \u8fd9\u91cc\u9700\u8981\u6839\u636e\u5b9e\u9645\u6570\u636e\u5e93\u8fde\u63a5\u8fdb\u884c\u914d\u7f6e<br \/>\n    # \u793a\u4f8b&#xff1a;\u8fde\u63a5\u5230SQLite\u6570\u636e\u5e93<br \/>\n    import sqlite3<br \/>\n    conn &#061; sqlite3.connect(&#039;https:\/\/vanna.ai\/Chinook.sqlite&#039;)<br \/>\n    return conn<\/p>\n<p># \u751f\u6210SQL\u67e5\u8be2<br \/>\ndef generate_sql(question):<br \/>\n    return vn.generate_sql(question)<\/p>\n<p># \u6267\u884c\u67e5\u8be2<br \/>\ndef execute_query(sql):<br \/>\n    conn &#061; get_database_connection()<br \/>\n    return pd.read_sql(sql, conn)<\/p>\n<p># \u751f\u6210\u53ef\u89c6\u5316\u56fe\u8868<br \/>\ndef generate_visualization(df, question):<br \/>\n    plotly_code &#061; vn.generate_plotly_code(question&#061;question, df&#061;df)<br \/>\n    fig &#061; vn.get_plotly_figure(plotly_code&#061;plotly_code, df&#061;df)<br \/>\n    return fig <\/p>\n<h3><\/h3>\n","protected":false},"excerpt":{"rendered":"<p>\u6587\u7ae0\u6d4f\u89c8\u9605\u8bfb309\u6b21\uff0c\u70b9\u8d5e6\u6b21\uff0c\u6536\u85cf4\u6b21\u3002Vanna\u662f\u4e00\u4e2a\u5f00\u6e90\u7684\u3001\u57fa\u4e8ePython\u7684RAG\uff08\u68c0\u7d22\u589e\u5f3a\u751f\u6210\uff09\u6846\u67b6\uff0c\u4e13\u95e8\u7528\u4e8eSQL\u751f\u6210\u548c\u76f8\u5173\u529f\u80fd\u3002\u5b83\u80fd\u5c06\u81ea\u7136\u8bed\u8a00\u95ee\u9898\u81ea\u52a8\u8f6c\u6210SQL\uff0c\u5e76\u4e14\u8fd8\u80fd\u76f4\u63a5\u8dd1\u5728\u6570\u636e\u5e93\u4e0a\uff0c\u81ea\u52a8\u751f\u6210\u53ef\u89c6\u5316\u56fe\u8868\u3002\u6613\u7528\u6027\uff1a\u5141\u8bb8\u975e\u6280\u672f\u7528\u6237\u901a\u8fc7\u81ea\u7136\u8bed\u8a00\u4e0e\u6570\u636e\u5e93\u4ea4\u4e92\uff0c\u65e0\u9700\u7f16\u5199\u590d\u6742\u7684SQL\u67e5\u8be2\u3002\u7075\u6d3b\u6027\uff1a\u53ef\u4ee5\u5904\u7406\u591a\u79cd\u7c7b\u578b\u7684\u6570\u636e\u5e93\u548c\u67e5\u8be2\uff0c\u9002\u7528\u4e8e\u4e0d\u540c\u7684\u5e94\u7528\u573a\u666f\u3002\u51c6\u786e\u6027\uff1aVanna\u7684\u80fd\u529b\u4e0e\u63d0\u4f9b\u7684\u8bad\u7ec3\u6570\u636e\u76f8\u5173\uff0c\u66f4\u591a\u7684\u8bad\u7ec3\u6570\u636e\u610f\u5473\u7740\u5728\u5927\u578b\u548c\u590d\u6742\u7684\u6570\u636e\u96c6\u4e0a\u6709\u66f4\u597d\u7684\u51c6\u786e\u6027\u3002\u5b89\u5168\u6027\uff1a\u6570\u636e\u5e93\u5185\u5bb9\u4e0d\u4f1a\u76f4\u63a5\u53d1\u9001\u7ed9LLM\uff0cSQL\u6267\u884c\u53d1\u751f\u5728\u672c\u5730\u73af\u5883\u4e2d\u3002\u81ea\u6211\u5b66\u4e60\u3002<\/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":[4140,4139,768,4138,100],"topic":[],"class_list":["post-44379","post","type-post","status-publish","format-standard","hentry","category-server","tag-ai","tag-bi","tag-sql","tag-vanna","tag-100"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v20.3 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>\u544a\u522b\u590d\u6742SQL\uff01Vanna\u95ee\u7b54\u5f15\u64ce\u6784\u5efa\u52a8\u6001\u53ef\u89c6\u5316\u62a5\u8868 - \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\/44379.html\" \/>\n<meta property=\"og:locale\" content=\"zh_CN\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"\u544a\u522b\u590d\u6742SQL\uff01Vanna\u95ee\u7b54\u5f15\u64ce\u6784\u5efa\u52a8\u6001\u53ef\u89c6\u5316\u62a5\u8868 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\" \/>\n<meta property=\"og:description\" content=\"\u6587\u7ae0\u6d4f\u89c8\u9605\u8bfb309\u6b21\uff0c\u70b9\u8d5e6\u6b21\uff0c\u6536\u85cf4\u6b21\u3002Vanna\u662f\u4e00\u4e2a\u5f00\u6e90\u7684\u3001\u57fa\u4e8ePython\u7684RAG\uff08\u68c0\u7d22\u589e\u5f3a\u751f\u6210\uff09\u6846\u67b6\uff0c\u4e13\u95e8\u7528\u4e8eSQL\u751f\u6210\u548c\u76f8\u5173\u529f\u80fd\u3002\u5b83\u80fd\u5c06\u81ea\u7136\u8bed\u8a00\u95ee\u9898\u81ea\u52a8\u8f6c\u6210SQL\uff0c\u5e76\u4e14\u8fd8\u80fd\u76f4\u63a5\u8dd1\u5728\u6570\u636e\u5e93\u4e0a\uff0c\u81ea\u52a8\u751f\u6210\u53ef\u89c6\u5316\u56fe\u8868\u3002\u6613\u7528\u6027\uff1a\u5141\u8bb8\u975e\u6280\u672f\u7528\u6237\u901a\u8fc7\u81ea\u7136\u8bed\u8a00\u4e0e\u6570\u636e\u5e93\u4ea4\u4e92\uff0c\u65e0\u9700\u7f16\u5199\u590d\u6742\u7684SQL\u67e5\u8be2\u3002\u7075\u6d3b\u6027\uff1a\u53ef\u4ee5\u5904\u7406\u591a\u79cd\u7c7b\u578b\u7684\u6570\u636e\u5e93\u548c\u67e5\u8be2\uff0c\u9002\u7528\u4e8e\u4e0d\u540c\u7684\u5e94\u7528\u573a\u666f\u3002\u51c6\u786e\u6027\uff1aVanna\u7684\u80fd\u529b\u4e0e\u63d0\u4f9b\u7684\u8bad\u7ec3\u6570\u636e\u76f8\u5173\uff0c\u66f4\u591a\u7684\u8bad\u7ec3\u6570\u636e\u610f\u5473\u7740\u5728\u5927\u578b\u548c\u590d\u6742\u7684\u6570\u636e\u96c6\u4e0a\u6709\u66f4\u597d\u7684\u51c6\u786e\u6027\u3002\u5b89\u5168\u6027\uff1a\u6570\u636e\u5e93\u5185\u5bb9\u4e0d\u4f1a\u76f4\u63a5\u53d1\u9001\u7ed9LLM\uff0cSQL\u6267\u884c\u53d1\u751f\u5728\u672c\u5730\u73af\u5883\u4e2d\u3002\u81ea\u6211\u5b66\u4e60\u3002\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.wsisp.com\/helps\/44379.html\" \/>\n<meta property=\"og:site_name\" content=\"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\" \/>\n<meta property=\"article:published_time\" content=\"2025-06-18T09:17:40+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\/44379.html\",\"url\":\"https:\/\/www.wsisp.com\/helps\/44379.html\",\"name\":\"\u544a\u522b\u590d\u6742SQL\uff01Vanna\u95ee\u7b54\u5f15\u64ce\u6784\u5efa\u52a8\u6001\u53ef\u89c6\u5316\u62a5\u8868 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\",\"isPartOf\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/#website\"},\"datePublished\":\"2025-06-18T09:17:40+00:00\",\"dateModified\":\"2025-06-18T09:17:40+00:00\",\"author\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41\"},\"breadcrumb\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/44379.html#breadcrumb\"},\"inLanguage\":\"zh-Hans\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.wsisp.com\/helps\/44379.html\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/44379.html#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"\u9996\u9875\",\"item\":\"https:\/\/www.wsisp.com\/helps\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"\u544a\u522b\u590d\u6742SQL\uff01Vanna\u95ee\u7b54\u5f15\u64ce\u6784\u5efa\u52a8\u6001\u53ef\u89c6\u5316\u62a5\u8868\"}]},{\"@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":"\u544a\u522b\u590d\u6742SQL\uff01Vanna\u95ee\u7b54\u5f15\u64ce\u6784\u5efa\u52a8\u6001\u53ef\u89c6\u5316\u62a5\u8868 - \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\/44379.html","og_locale":"zh_CN","og_type":"article","og_title":"\u544a\u522b\u590d\u6742SQL\uff01Vanna\u95ee\u7b54\u5f15\u64ce\u6784\u5efa\u52a8\u6001\u53ef\u89c6\u5316\u62a5\u8868 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","og_description":"\u6587\u7ae0\u6d4f\u89c8\u9605\u8bfb309\u6b21\uff0c\u70b9\u8d5e6\u6b21\uff0c\u6536\u85cf4\u6b21\u3002Vanna\u662f\u4e00\u4e2a\u5f00\u6e90\u7684\u3001\u57fa\u4e8ePython\u7684RAG\uff08\u68c0\u7d22\u589e\u5f3a\u751f\u6210\uff09\u6846\u67b6\uff0c\u4e13\u95e8\u7528\u4e8eSQL\u751f\u6210\u548c\u76f8\u5173\u529f\u80fd\u3002\u5b83\u80fd\u5c06\u81ea\u7136\u8bed\u8a00\u95ee\u9898\u81ea\u52a8\u8f6c\u6210SQL\uff0c\u5e76\u4e14\u8fd8\u80fd\u76f4\u63a5\u8dd1\u5728\u6570\u636e\u5e93\u4e0a\uff0c\u81ea\u52a8\u751f\u6210\u53ef\u89c6\u5316\u56fe\u8868\u3002\u6613\u7528\u6027\uff1a\u5141\u8bb8\u975e\u6280\u672f\u7528\u6237\u901a\u8fc7\u81ea\u7136\u8bed\u8a00\u4e0e\u6570\u636e\u5e93\u4ea4\u4e92\uff0c\u65e0\u9700\u7f16\u5199\u590d\u6742\u7684SQL\u67e5\u8be2\u3002\u7075\u6d3b\u6027\uff1a\u53ef\u4ee5\u5904\u7406\u591a\u79cd\u7c7b\u578b\u7684\u6570\u636e\u5e93\u548c\u67e5\u8be2\uff0c\u9002\u7528\u4e8e\u4e0d\u540c\u7684\u5e94\u7528\u573a\u666f\u3002\u51c6\u786e\u6027\uff1aVanna\u7684\u80fd\u529b\u4e0e\u63d0\u4f9b\u7684\u8bad\u7ec3\u6570\u636e\u76f8\u5173\uff0c\u66f4\u591a\u7684\u8bad\u7ec3\u6570\u636e\u610f\u5473\u7740\u5728\u5927\u578b\u548c\u590d\u6742\u7684\u6570\u636e\u96c6\u4e0a\u6709\u66f4\u597d\u7684\u51c6\u786e\u6027\u3002\u5b89\u5168\u6027\uff1a\u6570\u636e\u5e93\u5185\u5bb9\u4e0d\u4f1a\u76f4\u63a5\u53d1\u9001\u7ed9LLM\uff0cSQL\u6267\u884c\u53d1\u751f\u5728\u672c\u5730\u73af\u5883\u4e2d\u3002\u81ea\u6211\u5b66\u4e60\u3002","og_url":"https:\/\/www.wsisp.com\/helps\/44379.html","og_site_name":"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","article_published_time":"2025-06-18T09:17:40+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\/44379.html","url":"https:\/\/www.wsisp.com\/helps\/44379.html","name":"\u544a\u522b\u590d\u6742SQL\uff01Vanna\u95ee\u7b54\u5f15\u64ce\u6784\u5efa\u52a8\u6001\u53ef\u89c6\u5316\u62a5\u8868 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","isPartOf":{"@id":"https:\/\/www.wsisp.com\/helps\/#website"},"datePublished":"2025-06-18T09:17:40+00:00","dateModified":"2025-06-18T09:17:40+00:00","author":{"@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41"},"breadcrumb":{"@id":"https:\/\/www.wsisp.com\/helps\/44379.html#breadcrumb"},"inLanguage":"zh-Hans","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.wsisp.com\/helps\/44379.html"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/www.wsisp.com\/helps\/44379.html#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"\u9996\u9875","item":"https:\/\/www.wsisp.com\/helps"},{"@type":"ListItem","position":2,"name":"\u544a\u522b\u590d\u6742SQL\uff01Vanna\u95ee\u7b54\u5f15\u64ce\u6784\u5efa\u52a8\u6001\u53ef\u89c6\u5316\u62a5\u8868"}]},{"@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\/44379","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=44379"}],"version-history":[{"count":0,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts\/44379\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/media?parent=44379"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/categories?post=44379"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/tags?post=44379"},{"taxonomy":"topic","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/topic?post=44379"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}