{"id":164233,"date":"2024-11-05T06:09:28","date_gmt":"2024-11-04T22:09:28","guid":{"rendered":"https:\/\/server.hk\/cnblog\/164233\/"},"modified":"2024-11-05T06:09:29","modified_gmt":"2024-11-04T22:09:29","slug":"%e5%80%9f%e5%8a%a9rust%ef%bc%8c%e6%a5%b5%e5%a4%a7%e9%99%8d%e4%bd%8emssql%e6%95%b8%e6%93%9a%e5%ba%ab%e9%83%a8%e7%bd%b2%e6%88%90%e6%9c%ac%ef%bc%88rust-mssql%ef%bc%89","status":"publish","type":"post","link":"https:\/\/server.hk\/cnblog\/164233\/","title":{"rendered":"\u501f\u52a9Rust\uff0c\u6975\u5927\u964d\u4f4eMSSQL\u6578\u64da\u5eab\u90e8\u7f72\u6210\u672c\uff08rust mssql\uff09"},"content":{"rendered":"<h1 id=\"%e5%80%9f%e5%8a%a9rust%ef%bc%8c%e6%a5%b5%e5%a4%a7%e9%99%8d%e4%bd%8emssql%e6%95%b8%e6%93%9a%e5%ba%ab%e9%83%a8%e7%bd%b2%e6%88%90%e6%9c%ac-nyrTeKJIfg\">\u501f\u52a9Rust\uff0c\u6975\u5927\u964d\u4f4eMSSQL\u6578\u64da\u5eab\u90e8\u7f72\u6210\u672c<\/h1>\n<p>\u5728\u7576\u4eca\u7684\u6578\u64da\u9a45\u52d5\u6642\u4ee3\uff0c\u6578\u64da\u5eab\u7684\u6027\u80fd\u548c\u6210\u672c\u6548\u76ca\u6210\u70ba\u4f01\u696d\u6210\u529f\u7684\u95dc\u9375\u56e0\u7d20\u4e4b\u4e00\u3002\u96a8\u8457\u6280\u8853\u7684\u9032\u6b65\uff0cRust\u8a9e\u8a00\u56e0\u5176\u9ad8\u6548\u80fd\u548c\u5b89\u5168\u6027\u800c\u53d7\u5230\u8d8a\u4f86\u8d8a\u591a\u958b\u767c\u8005\u7684\u9752\u775e\u3002\u672c\u6587\u5c07\u63a2\u8a0e\u5982\u4f55\u5229\u7528Rust\u4f86\u964d\u4f4eMSSQL\u6578\u64da\u5eab\u7684\u90e8\u7f72\u6210\u672c\uff0c\u4e26\u63d0\u4f9b\u4e00\u4e9b\u5be6\u7528\u7684\u793a\u4f8b\u548c\u5efa\u8b70\u3002<\/p>\n<h2 id=\"rust%e8%aa%9e%e8%a8%80%e7%9a%84%e5%84%aa%e5%8b%a2-nyrTeKJIfg\">Rust\u8a9e\u8a00\u7684\u512a\u52e2<\/h2>\n<p>Rust\u662f\u4e00\u7a2e\u7cfb\u7d71\u7de8\u7a0b\u8a9e\u8a00\uff0c\u5177\u6709\u4ee5\u4e0b\u5e7e\u500b\u986f\u8457\u512a\u52e2\uff1a<\/p>\n<ul>\n<li><strong>\u9ad8\u6548\u80fd\uff1a<\/strong>Rust\u7684\u7de8\u8b6f\u5668\u80fd\u5920\u751f\u6210\u9ad8\u6548\u7684\u6a5f\u5668\u78bc\uff0c\u9019\u4f7f\u5f97Rust\u61c9\u7528\u7a0b\u5e8f\u5728\u57f7\u884c\u6642\u7684\u6027\u80fd\u63a5\u8fd1C\u548cC++\u3002<\/li>\n<li><strong>\u5167\u5b58\u5b89\u5168\uff1a<\/strong>Rust\u7684\u6240\u6709\u6b0a\u7cfb\u7d71\u80fd\u5920\u5728\u7de8\u8b6f\u6642\u6aa2\u67e5\u5167\u5b58\u5b89\u5168\u6027\uff0c\u5f9e\u800c\u6e1b\u5c11\u904b\u884c\u6642\u932f\u8aa4\u7684\u53ef\u80fd\u6027\u3002<\/li>\n<li><strong>\u4e26\u767c\u6027\uff1a<\/strong>Rust\u7684\u8a2d\u8a08\u4f7f\u5f97\u4e26\u767c\u7de8\u7a0b\u8b8a\u5f97\u66f4\u52a0\u7c21\u55ae\u548c\u5b89\u5168\uff0c\u9019\u5c0d\u65bc\u9700\u8981\u9ad8\u6548\u8655\u7406\u5927\u91cf\u6578\u64da\u7684\u6578\u64da\u5eab\u61c9\u7528\u5c24\u70ba\u91cd\u8981\u3002<\/li>\n<\/ul>\n<h2 id=\"mssql%e6%95%b8%e6%93%9a%e5%ba%ab%e7%9a%84%e9%83%a8%e7%bd%b2%e6%8c%91%e6%88%b0-nyrTeKJIfg\">MSSQL\u6578\u64da\u5eab\u7684\u90e8\u7f72\u6311\u6230<\/h2>\n<p>\u5728\u90e8\u7f72MSSQL\u6578\u64da\u5eab\u6642\uff0c\u4f01\u696d\u901a\u5e38\u9762\u81e8\u4ee5\u4e0b\u6311\u6230\uff1a<\/p>\n<ul>\n<li><strong>\u9ad8\u6602\u7684\u6388\u6b0a\u8cbb\u7528\uff1a<\/strong>MSSQL\u7684\u5546\u696d\u6388\u6b0a\u8cbb\u7528\u53ef\u80fd\u6703\u5c0d\u5c0f\u578b\u4f01\u696d\u9020\u6210\u8ca1\u52d9\u58d3\u529b\u3002<\/li>\n<li><strong>\u8cc7\u6e90\u9700\u6c42\uff1a<\/strong>MSSQL\u9700\u8981\u76f8\u5c0d\u8f03\u9ad8\u7684\u786c\u4ef6\u8cc7\u6e90\uff0c\u9019\u6703\u589e\u52a0\u90e8\u7f72\u6210\u672c\u3002<\/li>\n<li><strong>\u7dad\u8b77\u6210\u672c\uff1a<\/strong>\u6578\u64da\u5eab\u7684\u7dad\u8b77\u548c\u7ba1\u7406\u9700\u8981\u5c08\u696d\u7684\u6280\u8853\u4eba\u54e1\uff0c\u9019\u4e5f\u6703\u589e\u52a0\u4f01\u696d\u7684\u904b\u71df\u6210\u672c\u3002<\/li>\n<\/ul>\n<h2 id=\"%e5%a6%82%e4%bd%95%e5%88%a9%e7%94%a8rust%e9%99%8d%e4%bd%8e%e9%83%a8%e7%bd%b2%e6%88%90%e6%9c%ac-nyrTeKJIfg\">\u5982\u4f55\u5229\u7528Rust\u964d\u4f4e\u90e8\u7f72\u6210\u672c<\/h2>\n<p>\u5229\u7528Rust\u8a9e\u8a00\u7684\u7279\u6027\uff0c\u4f01\u696d\u53ef\u4ee5\u5728\u591a\u500b\u65b9\u9762\u964d\u4f4eMSSQL\u6578\u64da\u5eab\u7684\u90e8\u7f72\u6210\u672c\uff1a<\/p>\n<h3 id=\"1-%e9%96%8b%e6%ba%90%e6%9b%bf%e4%bb%a3%e6%96%b9%e6%a1%88-nyrTeKJIfg\">1. \u958b\u6e90\u66ff\u4ee3\u65b9\u6848<\/h3>\n<p>\u96d6\u7136MSSQL\u662f\u4e00\u500b\u5f37\u5927\u7684\u5546\u696d\u6578\u64da\u5eab\uff0c\u4f46\u5e02\u5834\u4e0a\u4e5f\u6709\u8a31\u591a\u958b\u6e90\u7684\u6578\u64da\u5eab\u89e3\u6c7a\u65b9\u6848\uff0c\u5982PostgreSQL\u548cMySQL\u3002\u9019\u4e9b\u958b\u6e90\u6578\u64da\u5eab\u53ef\u4ee5\u8207Rust\u9032\u884c\u96c6\u6210\uff0c\u4e26\u4e14\u4e0d\u9700\u8981\u652f\u4ed8\u9ad8\u6602\u7684\u6388\u6b0a\u8cbb\u7528\u3002\u958b\u767c\u8005\u53ef\u4ee5\u4f7f\u7528Rust\u7684\u6578\u64da\u5eab\u9a45\u52d5\u7a0b\u5e8f\uff0c\u5982<code>sqlx<\/code>\uff0c\u4f86\u8207\u9019\u4e9b\u6578\u64da\u5eab\u9032\u884c\u4ea4\u4e92\u3002<\/p>\n<pre><code>\nuse sqlx::postgres::PgPoolOptions;\n\n#[tokio::main]\nasync fn main() {\n    let pool = PgPoolOptions::new()\n        .max_connections(5)\n        .connect(\"postgres:\/\/user:password@localhost\/database\")\n        .await\n        .unwrap();\n}\n<\/code><\/pre>\n<h3 id=\"2-%e6%8f%90%e9%ab%98%e6%80%a7%e8%83%bd-nyrTeKJIfg\">2. \u63d0\u9ad8\u6027\u80fd<\/h3>\n<p>Rust\u7684\u9ad8\u6548\u80fd\u7279\u6027\u4f7f\u5f97\u958b\u767c\u8005\u80fd\u5920\u7de8\u5beb\u6027\u80fd\u512a\u8d8a\u7684\u6578\u64da\u8655\u7406\u4ee3\u78bc\u3002\u9019\u610f\u5473\u8457\u5728\u76f8\u540c\u7684\u786c\u4ef6\u8cc7\u6e90\u4e0b\uff0cRust\u61c9\u7528\u7a0b\u5e8f\u53ef\u4ee5\u8655\u7406\u66f4\u591a\u7684\u8acb\u6c42\uff0c\u5f9e\u800c\u964d\u4f4e\u4e86\u5c0d\u786c\u4ef6\u7684\u9700\u6c42\u3002\u4f8b\u5982\uff0c\u4f7f\u7528Rust\u7de8\u5beb\u7684\u6578\u64da\u8655\u7406\u670d\u52d9\u53ef\u4ee5\u5728\u8655\u7406\u5927\u91cf\u67e5\u8a62\u6642\u4fdd\u6301\u4f4e\u5ef6\u9072\uff0c\u9019\u5c0d\u65bc\u6578\u64da\u5eab\u7684\u6027\u80fd\u81f3\u95dc\u91cd\u8981\u3002<\/p>\n<h3 id=\"3-%e9%99%8d%e4%bd%8e%e7%b6%ad%e8%ad%b7%e6%88%90%e6%9c%ac-nyrTeKJIfg\">3. \u964d\u4f4e\u7dad\u8b77\u6210\u672c<\/h3>\n<p>\u7531\u65bcRust\u7684\u5167\u5b58\u5b89\u5168\u6027\u548c\u4e26\u767c\u6027\uff0c\u958b\u767c\u8005\u53ef\u4ee5\u66f4\u8f15\u9b06\u5730\u7de8\u5beb\u548c\u7dad\u8b77\u4ee3\u78bc\u3002\u9019\u4e0d\u50c5\u6e1b\u5c11\u4e86\u932f\u8aa4\u7684\u767c\u751f\u7387\uff0c\u9084\u964d\u4f4e\u4e86\u5c0d\u5c08\u696d\u6280\u8853\u4eba\u54e1\u7684\u9700\u6c42\u3002\u4f01\u696d\u53ef\u4ee5\u5229\u7528\u9019\u4e00\u9ede\uff0c\u5c07\u8cc7\u6e90\u96c6\u4e2d\u5728\u5176\u4ed6\u91cd\u8981\u7684\u696d\u52d9\u9818\u57df\u3002<\/p>\n<h2 id=\"%e7%b5%90%e8%ab%96-nyrTeKJIfg\">\u7d50\u8ad6<\/h2>\n<p>\u7e3d\u7684\u4f86\u8aaa\uff0cRust\u8a9e\u8a00\u70ba\u4f01\u696d\u63d0\u4f9b\u4e86\u4e00\u7a2e\u6709\u6548\u7684\u65b9\u5f0f\u4f86\u964d\u4f4eMSSQL\u6578\u64da\u5eab\u7684\u90e8\u7f72\u6210\u672c\u3002\u901a\u904e\u9078\u64c7\u958b\u6e90\u66ff\u4ee3\u65b9\u6848\u3001\u63d0\u9ad8\u6027\u80fd\u4ee5\u53ca\u964d\u4f4e\u7dad\u8b77\u6210\u672c\uff0c\u4f01\u696d\u53ef\u4ee5\u5728\u4e0d\u59a5\u5354\u6578\u64da\u5eab\u6027\u80fd\u7684\u60c5\u6cc1\u4e0b\uff0c\u5be6\u73fe\u66f4\u9ad8\u7684\u6210\u672c\u6548\u76ca\u3002\u96a8\u8457Rust\u751f\u614b\u7cfb\u7d71\u7684\u4e0d\u65b7\u767c\u5c55\uff0c\u672a\u4f86\u5c07\u6703\u6709\u66f4\u591a\u7684\u5de5\u5177\u548c\u5eab\u53ef\u4f9b\u958b\u767c\u8005\u4f7f\u7528\uff0c\u9032\u4e00\u6b65\u4fc3\u9032\u6578\u64da\u5eab\u6280\u8853\u7684\u5275\u65b0\u3002<\/p>\n<p>\u5982\u679c\u60a8\u6b63\u5728\u5c0b\u627e\u9ad8\u6548\u80fd\u7684\u89e3\u6c7a\u65b9\u6848\u4f86\u90e8\u7f72\u60a8\u7684\u6578\u64da\u5eab\uff0c\u8003\u616e\u4f7f\u7528<a href=\"https:\/\/server.hk\">\u9999\u6e2fVPS<\/a>\u670d\u52d9\uff0c\u9019\u5c07\u70ba\u60a8\u7684\u696d\u52d9\u63d0\u4f9b\u7a69\u5b9a\u548c\u53ef\u9760\u7684\u652f\u6301\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u5229\u7528Rust\u6280\u8853\uff0c\u986f\u8457\u964d\u4f4eMSSQL\u6578\u64da\u5eab\u7684\u90e8\u7f72\u6210\u672c\uff0c\u63d0\u5347\u6027\u80fd\u8207\u6548\u7387\uff0c\u52a9\u529b\u4f01\u696d\u512a\u5316\u8cc7\u6e90\u914d\u7f6e\u3002<\/p>\n","protected":false},"author":0,"featured_media":0,"comment_status":"closed","ping_status":"","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[101],"tags":[],"class_list":["post-164233","post","type-post","status-publish","format-standard","hentry","category-database"],"_links":{"self":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts\/164233","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"}],"replies":[{"embeddable":true,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/comments?post=164233"}],"version-history":[{"count":1,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts\/164233\/revisions"}],"predecessor-version":[{"id":164234,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts\/164233\/revisions\/164234"}],"wp:attachment":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/media?parent=164233"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/categories?post=164233"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/tags?post=164233"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}