{"id":200765,"date":"2025-05-06T10:57:59","date_gmt":"2025-05-06T02:57:59","guid":{"rendered":"https:\/\/server.hk\/cnblog\/200765\/"},"modified":"2025-05-06T10:57:59","modified_gmt":"2025-05-06T02:57:59","slug":"%e5%a6%82%e4%bd%95%e7%9c%81%e7%95%a5-python-orm-%e6%a8%a1%e5%9e%8b%e7%b1%bb%e7%bc%96%e5%86%99%ef%bc%9f","status":"publish","type":"post","link":"https:\/\/server.hk\/cnblog\/200765\/","title":{"rendered":"\u5982\u4f55\u7701\u7565 Python ORM \u6a21\u578b\u7c7b\u7f16\u5199\uff1f"},"content":{"rendered":"<p><b><\/b> <\/p>\n<h1>\u5982\u4f55\u7701\u7565 Python ORM \u6a21\u578b\u7c7b\u7f16\u5199\uff1f<\/h1>\n<p>\u7f16\u7a0b\u5e76\u4e0d\u662f\u4e00\u4e2a\u673a\u68b0\u6027\u7684\u5de5\u4f5c\uff0c\u800c\u662f\u9700\u8981\u6709\u601d\u8003\uff0c\u6709\u521b\u65b0\u7684\u5de5\u4f5c\uff0c\u8bed\u6cd5\u662f\u56fa\u5b9a\u7684\uff0c\u4f46\u89e3\u51b3\u95ee\u9898\u7684\u601d\u8def\u5219\u662f\u4f9d\u9760\u4eba\u7684\u601d\u7ef4\uff0c\u8fd9\u5c31\u9700\u8981\u6211\u4eec\u575a\u6301\u5b66\u4e60\u548c\u66f4\u65b0\u81ea\u5df1\u7684\u77e5\u8bc6\u3002\u4eca\u5929\u4e3b\u673a\u5b9d\u8d1d\u5c31\u6574\u7406\u5206\u4eab\u300a\u5982\u4f55\u7701\u7565 Python ORM \u6a21\u578b\u7c7b\u7f16\u5199\uff1f\u300b\uff0c\u6587\u7ae0\u8bb2\u89e3\u7684\u77e5\u8bc6\u70b9\u4e3b\u8981\u5305\u62ec\uff0c\u5982\u679c\u4f60\u5bf9\u6570\u636e\u5e93\u65b9\u9762\u7684\u77e5\u8bc6\u70b9\u611f\u5174\u8da3\uff0c\u5c31\u4e0d\u8981\u9519\u8fc7\u4e3b\u673a\u5b9d\u8d1d\uff0c\u5728\u8fd9\u53ef\u4ee5\u5bf9\u5927\u5bb6\u7684\u77e5\u8bc6\u79ef\u7d2f\u6709\u6240\u5e2e\u52a9\uff0c\u52a9\u529b\u5f00\u53d1\u80fd\u529b\u7684\u63d0\u5347\u3002<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/www.17golang.com\/uploads\/20241114\/1731552709673565c5d984d.jpg\" class=\"aligncenter\"><\/p>\n<p><strong>Python ORM \u5e93\u5982\u4f55\u7701\u7565\u6a21\u578b\u7c7b\u7f16\u5199<\/strong><\/p>\n<p>\u5728\u4f7f\u7528 Python ORM \u8fdb\u884c\u6570\u636e\u5e93\u4ea4\u4e92\u65f6\uff0c\u901a\u5e38\u9700\u8981\u7f16\u5199\u6a21\u578b\u7c7b\u6765\u5b9a\u4e49\u8868\u7684\u7ed3\u6784\u548c\u5b57\u6bb5\u6620\u5c04\u3002\u8fd9\u53ef\u80fd\u4f1a\u5728\u6bcf\u6b21\u67e5\u8be2\u65b0\u8868\u65f6\u5e26\u6765\u7e41\u7410\u7684\u5de5\u4f5c\u3002\u672c\u6587\u63a2\u8ba8\u4e86\u53ef\u4ee5\u7701\u53bb\u6a21\u578b\u7c7b\u7f16\u5199\u7684\u65b9\u6cd5\u6216 ORM \u5e93\u3002<\/p>\n<p><strong>ORM \u5e93\u4e2d\u7684 DbFirst \u65b9\u6cd5<\/strong><\/p>\n<p>\u4e00\u4e9b ORM \u5e93\u63d0\u4f9b\u4e86 DbFirst \u65b9\u6cd5\uff0c\u5373\u9996\u5148\u5b9a\u4e49\u8868\u7ed3\u6784\uff0c\u7136\u540e\u6839\u636e\u8868\u7ed3\u6784\u81ea\u52a8\u751f\u6210\u6a21\u578b\u7c7b\u6216\u5b57\u6bb5\u6620\u5c04\u3002\u4f8b\u5982\uff1a<\/p>\n<p><strong>Django<\/strong><\/p>\n<p>Django \u540c\u65f6\u652f\u6301 CodeFirst \u548c DbFirst\uff0c\u5982\u679c\u4f60\u4ec5\u5b9a\u4e49\u8868\u7ed3\u6784\uff0cDjango \u53ef\u4ee5\u6839\u636e\u8868\u7ed3\u6784\u751f\u6210\u6a21\u578b\u7c7b\u3002<\/p>\n<p><strong>\u5176\u4ed6\u6846\u67b6<\/strong><\/p>\n<p>\u5176\u4ed6\u6846\u67b6\uff0c\u5982 Flask\uff0c\u4e5f\u53ef\u4ee5\u4f7f\u7528\u7b2c\u4e09\u65b9\u5e93\u6765\u5b9e\u73b0 DbFirst \u529f\u80fd\u3002\u4f60\u53ef\u4ee5\u641c\u7d22 &#8220;Flask + DbFirst&#8221; \u4ee5\u83b7\u53d6\u66f4\u591a\u4fe1\u606f\u3002<\/p>\n<p><strong>\u53e6\u4e00\u79cd\u65b9\u6cd5\uff1a\u76f4\u63a5\u67e5\u8be2\u8868<\/strong><\/p>\n<p>\u5982\u679c\u4f60\u4e0d\u60f3\u4f7f\u7528 ORM\uff0c\u4e5f\u53ef\u4ee5\u76f4\u63a5\u4f7f\u7528 SQL \u8bed\u53e5\u67e5\u8be2\u8868\uff0c\u65e0\u9700\u7f16\u5199\u6a21\u578b\u7c7b\u3002\u8fd9\u53ef\u80fd\u4f1a\u5e26\u6765\u4e00\u4e9b\u989d\u5916\u7684\u7075\u6d3b\u6027\uff0c\u4f46\u9700\u8981\u4f60\u719f\u6089 SQL \u8bed\u6cd5\u3002<\/p>\n<p><strong>\u603b\u7ed3<\/strong><\/p>\n<p>\u867d\u7136\u7f16\u5199\u6a21\u578b\u7c7b\u901a\u5e38\u662f ORM \u4f7f\u7528\u4e2d\u5fc5\u4e0d\u53ef\u5c11\u7684\u4e00\u90e8\u5206\uff0c\u4f46\u4f7f\u7528 DbFirst \u65b9\u6cd5\u6216\u5176\u4ed6\u6280\u672f\u53ef\u4ee5\u5728\u67d0\u4e9b\u60c5\u51b5\u4e0b\u7701\u7565\u8fd9\u4e00\u6b65\u9aa4\u3002\u6839\u636e\u5177\u4f53\u9700\u6c42\u548c\u504f\u597d\uff0c\u4f60\u53ef\u4ee5\u9009\u62e9\u6700\u9002\u5408\u7684\u65b9\u6cd5\u3002<\/p>\n<p>\u4ee5\u4e0a\u5c31\u662f\u672c\u6587\u7684\u5168\u90e8\u5185\u5bb9\u4e86\uff0c\u662f\u5426\u6709\u987a\u5229\u5e2e\u52a9\u4f60\u89e3\u51b3\u95ee\u9898\uff1f\u82e5\u662f\u80fd\u7ed9\u4f60\u5e26\u6765\u5b66\u4e60\u4e0a\u7684\u5e2e\u52a9\uff0c\u8bf7\u5927\u5bb6\u591a\u591a\u652f\u6301\u4e3b\u673a\u5b9d\u8d1d\uff01\u66f4\u591a\u5173\u4e8e\u6570\u636e\u5e93\u7684\u76f8\u5173\u77e5\u8bc6\uff0c\u4e5f\u53ef\u5173\u6ce8\u4e3b\u673a\u5b9d\u8d1d\u516c\u4f17\u53f7\u3002<\/p>\n<dl>\n<dt>\n <\/dt>\n<\/dl>\n","protected":false},"excerpt":{"rendered":"<p>\u5982\u4f55\u7701\u7565 Python ORM &#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":[101],"tags":[],"class_list":["post-200765","post","type-post","status-publish","format-standard","hentry","category-database"],"_links":{"self":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts\/200765","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=200765"}],"version-history":[{"count":0,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts\/200765\/revisions"}],"wp:attachment":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/media?parent=200765"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/categories?post=200765"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/tags?post=200765"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}