{"id":204472,"date":"2025-05-29T08:47:36","date_gmt":"2025-05-29T00:47:36","guid":{"rendered":"https:\/\/server.hk\/cnblog\/204472\/"},"modified":"2025-05-29T08:47:36","modified_gmt":"2025-05-29T00:47:36","slug":"python-%e5%ae%a2%e6%88%b7%e7%ab%af%e5%a6%82%e4%bd%95%e4%bc%98%e9%9b%85%e5%9c%b0%e5%ae%9e%e7%8e%b0-sql-%e6%9f%a5%e8%af%a2%e8%b6%85%e6%97%b6%ef%bc%9f","status":"publish","type":"post","link":"https:\/\/server.hk\/cnblog\/204472\/","title":{"rendered":"Python \u5ba2\u6237\u7aef\u5982\u4f55\u4f18\u96c5\u5730\u5b9e\u73b0 SQL \u67e5\u8be2\u8d85\u65f6\uff1f"},"content":{"rendered":"<p><b><\/b>     <\/p>\n<h1>Python \u5ba2\u6237\u7aef\u5982\u4f55\u4f18\u96c5\u5730\u5b9e\u73b0 SQL \u67e5\u8be2\u8d85\u65f6\uff1f<\/h1>\n<p>\u4e00\u5206\u8015\u8018\uff0c\u4e00\u5206\u6536\u83b7\uff01\u65e2\u7136\u6253\u5f00\u4e86\u8fd9\u7bc7\u6587\u7ae0\uff0c\u5c31\u575a\u6301\u770b\u4e0b\u53bb\u5427\uff01\u6587\u4e2d\u5185\u5bb9\u5305\u542b<span style=\"color: #FF6600;, Helvetica, Arial, sans-serif;font-size: 14px;background-color: #FFFFFF\"><\/span>\u7b49\u7b49\u77e5\u8bc6\u70b9&#8230;\u5e0c\u671b\u4f60\u80fd\u5728\u9605\u8bfb\u672c\u6587\u540e\uff0c\u80fd\u771f\u771f\u5b9e\u5b9e\u5b66\u5230\u77e5\u8bc6\u6216\u8005\u5e2e\u4f60\u89e3\u51b3\u5fc3\u4e2d\u7684\u7591\u60d1\uff0c\u4e5f\u6b22\u8fce\u5927\u4f6c\u6216\u8005\u65b0\u4eba\u670b\u53cb\u4eec\u591a\u7559\u8a00\u8bc4\u8bba\uff0c\u591a\u7ed9\u5efa\u8bae\uff01\u8c22\u8c22\uff01<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/www.17golang.com\/uploads\/20241108\/1731059307672dde6b37790.jpg\" class=\"aligncenter\"><\/p>\n<p><strong>\u5728 Python \u5ba2\u6237\u7aef\u5b9e\u73b0 SQL \u67e5\u8be2\u8d85\u65f6<\/strong><\/p>\n<p>\u5728\u4f7f\u7528 Django ORM\u3001Peewee\u3001SQLAlchemy \u7b49 ORM \u6846\u67b6\uff1bPyMySQL \u7b49\u9a71\u52a8\u5e93\uff1bFastAPI\u3001Flask\u3001Django \u7b49\u5e94\u7528\u6846\u67b6\uff1bUvicorn\u3001Gunicorn \u7b49\u670d\u52a1\u5668\u65f6\uff0c\u4e3a\u4e86\u9632\u6b62 SQL \u67e5\u8be2\u65f6\u95f4\u8fc7\u957f\u5e26\u6765\u7684\u5b89\u5168\u9690\u60a3\uff0c\u6211\u4eec\u9700\u8981\u8bbe\u7f6e\u4e00\u4e2a\u67e5\u8be2\u65f6\u95f4\u4e0a\u9650\u3002<\/p>\n<p>\u5982\u4f55\u4f18\u96c5\u5730\u5b9e\u73b0\u6b64\u529f\u80fd\uff1f\u4e00\u79cd\u65b9\u6cd5\u662f\u4f7f\u7528 PyMySQL \u7684\u4ee5\u4e0b\u53c2\u6570\uff1a<\/p>\n<ul>\n<li>&#8220;connection_timeout&#8221;: 60<\/li>\n<li>&#8220;read_timeout&#8221;: 60<\/li>\n<li>&#8220;write_timeout&#8221;: 60<\/li>\n<\/ul>\n<p>\u8fd9\u4e9b\u53c2\u6570\u5206\u522b\u6307\u5b9a\u6570\u636e\u5e93\u8fde\u63a5\u3001\u8bfb\u53d6\u64cd\u4f5c\u548c\u5199\u5165\u64cd\u4f5c\u7684\u8d85\u65f6\u65f6\u95f4\u3002\u4ee5\u79d2\u4e3a\u5355\u4f4d\u3002\u5982\u4e0a\u4f8b\u6240\u793a\uff0c\u8d85\u65f6\u65f6\u95f4\u8bbe\u7f6e\u4e3a 60 \u79d2\u3002\u8fd9\u6837\uff0c\u4efb\u4f55\u6301\u7eed\u65f6\u95f4\u8d85\u8fc7 60 \u79d2\u7684 SQL \u67e5\u8be2\u90fd\u4f1a\u88ab\u7ec8\u6b62\u3002<\/p>\n<p>\u6ce8\u610f\uff0c\u8bbe\u7f6e\u8d85\u65f6\u65f6\u95f4\u8981\u6c42\u5728\u5ba2\u6237\u7aef\u8fdb\u884c\uff0c\u4e0d\u80fd\u4fee\u6539 MySQL \u670d\u52a1\u5668\uff0c\u56e0\u4e3a\u6570\u636e\u5e93\u53ef\u80fd\u662f\u4f9b\u591a\u4eba\u4f7f\u7528\u7684\u3002<\/p>\n<p>\u5230\u8fd9\u91cc\uff0c\u6211\u4eec\u4e5f\u5c31\u8bb2\u5b8c\u4e86\u300aPython \u5ba2\u6237\u7aef\u5982\u4f55\u4f18\u96c5\u5730\u5b9e\u73b0 SQL \u67e5\u8be2\u8d85\u65f6\uff1f\u300b\u7684\u5185\u5bb9\u4e86\u3002\u4e2a\u4eba\u8ba4\u4e3a\uff0c\u57fa\u7840\u77e5\u8bc6\u7684\u5b66\u4e60\u548c\u5de9\u56fa\uff0c\u662f\u4e3a\u4e86\u66f4\u597d\u7684\u5c06\u5176\u8fd0\u7528\u5230\u9879\u76ee\u4e2d\uff0c\u6b22\u8fce\u5173\u6ce8\u516c\u4f17\u53f7\uff0c\u5e26\u4f60\u4e86\u89e3\u66f4\u591a\u5173\u4e8e\u7684\u77e5\u8bc6\u70b9\uff01<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Python \u5ba2\u6237\u7aef\u5982\u4f55\u4f18\u96c5\u5730\u5b9e&#46;&#46;&#46;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[4925],"tags":[],"class_list":["post-204472","post","type-post","status-publish","format-standard","hentry","category-4925"],"_links":{"self":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts\/204472","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/comments?post=204472"}],"version-history":[{"count":0,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts\/204472\/revisions"}],"wp:attachment":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/media?parent=204472"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/categories?post=204472"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/tags?post=204472"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}