{"id":102504,"date":"2020-05-03T09:32:36","date_gmt":"2020-05-03T01:32:36","guid":{"rendered":"http:\/\/4563.org\/?p=102504"},"modified":"2020-05-03T09:32:36","modified_gmt":"2020-05-03T01:32:36","slug":"%e8%af%b7%e6%95%99-sqlalchemy-%e8%bf%99%e4%b8%a4%e4%b8%aa%e6%93%8d%e4%bd%9c-%ef%bc%88%e6%b8%85%e7%a9%ba%e8%a1%a8%e3%80%81%e9%87%8d%e7%bd%ae%e8%87%aa%e5%a2%9e%e9%95%bf-id","status":"publish","type":"post","link":"http:\/\/4563.org\/?p=102504","title":{"rendered":"\u8bf7\u6559 sqlalchemy \u8fd9\u4e24\u4e2a\u64cd\u4f5c&#8230;\uff08\u6e05\u7a7a\u8868\u3001\u91cd\u7f6e\u81ea\u589e\u957f id)"},"content":{"rendered":"<div>\n<div>\n<div>\n<h1>                  \u8bf7\u6559 sqlalchemy \u8fd9\u4e24\u4e2a\u64cd\u4f5c&#8230;\uff08\u6e05\u7a7a\u8868\u3001\u91cd\u7f6e\u81ea\u589e\u957f id)               <\/h1>\n<p> <\/p>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : qazwsxkevin <\/span>  <span><i><\/i> 51<\/span> <\/div>\n<div> <\/div>\n<\/p><\/div>\n<\/p><\/div>\n<\/p><\/div>\n<div isfirst=\"1\"> <\/p>\n<p>\u4ee5\u524d\u7528 Core \u6a21\u5f0f\u64cd\u4f5c\u6570\u636e\u5e93\uff0c\u6211\u662f\u8fd9\u6837\u64cd\u4f5c\u7684\uff1a<\/p>\n<pre><code>SQLResult = sqlconn.execute(f\"TRUNCATE TABLE `newadd`;\") print(\"\u6e05\u7a7a [newadd] \u8868...\")  SQLResult = sqlconn.execute(f\"ALTER  TABLE  `newadd` DROP `id`;\") print(\"\u53bb\u9664 [newadd] \u8868 [id] \u5217...\")  SQLResult = sqlconn.execute(f\"ALTER  TABLE  `newadd` ADD id int(11) PRIMARY KEY NOT NULL AUTO_INCREMENT FIRST;\") print(\"[newadd] \u8868 \u589e\u52a0 [id] \u5217...\") <\/code><\/pre>\n<p>\u73b0\u5728\u8868\u7684\u8bbe\u8ba1\uff0c\u5df2\u7ecf\u7a33\u5b9a\u4e0b\u6765\u4e86\uff0c\u4e3a\u4e86\u65b9\u4fbf query\uff0cupdate \u7b49\u64cd\u4f5c\uff0c\u5927\u90e8\u5206\u8868\u6539\u6210 ORM \u65b9\u5f0f\u53bb\u64cd\u4f5c\uff0c<br \/> \u770b\u4e86 sqlalchemy \u7684\u5b98\u65b9\u6587\u6863\u548c\u4e00\u4e9b\u7f51\u4e0a\u627e\u5230\u7684\u8d44\u6599\uff0c\u4f3c\u4e4e\u6e05\u8868\uff0c\u91cd\u7f6e\u81ea\u589e\u957f id \u8fd9\u4e9b\u64cd\u4f5c\uff0c\u9664\u4e86\u76f4\u63a5\u6267\u884c\u539f\u751f sql \u8bed\u53e5\uff0c\u4f3c\u4e4e\u6ca1\u6709\u4ec0\u4e48\u66f4\u597d\u7684 ORM \u5c01\u88c5\u64cd\u4f5c\u4e86\u5427\uff1f<\/p>\n<\/p><\/div>\n<div> <b>\u5927\u4f6c\u6709\u8a71\u8aaa<\/b> (<span>2<\/span>)        <\/div>\n<div> <\/div>\n<\/p><\/div>\n<\/p><\/div>\n<ul>\n<li data-pid=\"681721\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : qile1 <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             sqlalchemy \u53ef\u4ee5\u66f4\u65b0\u81ea\u589e id \u7684\uff0c\u76f8\u5f53\u4e8e select updata<br \/>\u767e\u5ea6\u4e00\u4e0b\u4e5f\u4f1a\u6709\u7684\uff0c\u4f46\u662f\u94fe\u63a5 mssql \u6570\u636e\u5e93\u5c31\u4e0d\u597d\u641e\u4e86. \uff0cflask \u4e00\u76f4\u4e0d\u884c                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"681722\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u4e3b<\/span> <span>\u8cc7\u6df1\u5927\u4f6c : qazwsxkevin <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             @qile1 \u8c22\u8c22\u89e3\u7b54\uff0c\u8eab\u8fb9\u4e5f\u53ea\u662f\u6211\u4e00\u4e2a\u5728\u6363\u9f13 sqlalchemy\uff0c\u6ca1\u6709\u529e\u6cd5\u6c42\u8bc1\u4e00\u4e9b\u4e8b\u60c5\uff0c\u53ea\u80fd\u53d1\u5e16\u6c42\u4e2a\u56de\u54cd <br \/>\u786c\u6838\u4e00\u4e9b\uff0c\u76f4\u63a5.execute \u7ec4\u88c5\u7684 str \u7c7b\u578b\u539f\u751f sql \u8bed\u53e5\uff0c\u5176\u5b9e\u95ee\u9898\u4e5f\u4e0d\u5927\uff0c\u53ea\u662f\u6211\u521a\u4ece Core \u6a21\u5f0f\u8f6c\u6362\u5230 ORM \u6a21\u5f0f\u6765\u64cd\u4f5c\uff0c\u60f3\u6c42\u8bc1\u4e00\u4e0b ORM \u662f\u5426\u6709\u8fd9\u79cd\u64cd\u4f5c\u800c\u5df2\uff0c\u6216\u8005\u8fd8\u6709\u66f4\u597d\u7684 ORM API\uff0c\u6216\u8005\u9ad8\u624b\u5c01\u88c5\u5f97\u66f4\u597d\u7684\u8f6e\u5b50\u3002\u3002\u3002^_^                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li>\n","protected":false},"excerpt":{"rendered":"<p>\u8bf7\u6559 sqlalchemy \u8fd9\u4e24\u4e2a&hellip;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[],"tags":[],"_links":{"self":[{"href":"http:\/\/4563.org\/index.php?rest_route=\/wp\/v2\/posts\/102504"}],"collection":[{"href":"http:\/\/4563.org\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/4563.org\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/4563.org\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/4563.org\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=102504"}],"version-history":[{"count":0,"href":"http:\/\/4563.org\/index.php?rest_route=\/wp\/v2\/posts\/102504\/revisions"}],"wp:attachment":[{"href":"http:\/\/4563.org\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=102504"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/4563.org\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=102504"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/4563.org\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=102504"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}