{"id":210542,"date":"2020-11-30T15:32:27","date_gmt":"2020-11-30T07:32:27","guid":{"rendered":"http:\/\/4563.org\/?p=210542"},"modified":"2020-11-30T15:32:27","modified_gmt":"2020-11-30T07:32:27","slug":"pymysql-%e6%89%a7%e8%a1%8c%e6%8a%a5%e9%94%99%ef%bc%8c%e5%a4%a7%e4%bd%ac%e4%bb%ac%e5%b8%ae%e5%bf%99%e7%9c%8b%e7%9c%8b","status":"publish","type":"post","link":"http:\/\/4563.org\/?p=210542","title":{"rendered":"pymysql \u6267\u884c\u62a5\u9519\uff0c\u5927\u4f6c\u4eec\u5e2e\u5fd9\u770b\u770b"},"content":{"rendered":"<div>\n<div>\n<div>\n<h1>                  pymysql \u6267\u884c\u62a5\u9519\uff0c\u5927\u4f6c\u4eec\u5e2e\u5fd9\u770b\u770b               <\/h1>\n<p> <\/p>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : gyy028012 <\/span>  <span><i><\/i> 0<\/span> <\/div>\n<div> <\/div>\n<\/p><\/div>\n<\/p><\/div>\n<\/p><\/div>\n<div isfirst=\"1\">                        \u4f7f\u7528 pymysql \u7684 execute \u65b9\u6cd5\u6267\u884c SQL \u8bed\u53e5<\/p>\n<p>SQL \u8bed\u53e5\u5982\u4e0b\uff1a<br \/>SET @days := 10;<br \/>SELECT @days as &#8216;days&#8217;;<\/p>\n<p>\u62a5\u8bed\u6cd5\u9519\u8bef<br \/>(1064, &#8220;You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near &#8216;SELECT @days AS &#8216;days&#8221; at line 4&#8243;)<\/p>\n<p>\u8fd9\u4e2a SQL \u8bed\u53e5\u5728 navicat \u4e0a\u662f\u53ef\u4ee5\u6267\u884c\u7684<\/p>\n<p>\u6709\u5927\u4f6c\u5e2e\u5fd9\u6307\u70b9\u8ff7\u6d25\u5417      <\/p><\/div>\n<div> <b>\u5927\u4f6c\u6709\u8a71\u8aaa<\/b> (<span>3<\/span>)        <\/div>\n<div> <\/div>\n<\/p><\/div>\n<\/p><\/div>\n<ul>\n<li data-pid=\"4367687\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : smallpython <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             \u60f3\u95ee\u4e0b\u8fd9\u4e2a\u8bed\u6cd5\u662f\u4ec0\u4e48\u542b\u4e49                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"4367688\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : tmackan <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             \u8d34\u4e0b\u4f60\u7684 py \u4ee3\u7801\u5e94\u8be5\uff0c<br \/>\u5982\u4e0a sql \u76f4\u63a5\u5230 mysql \u6267\u884c\u662f\u6ca1\u95ee\u9898\u7684<br \/>@smallpython \u8bbe\u7f6e\u4e2a\u8fd0\u884c\u65f6\u5168\u5c40\u53d8\u91cf\u800c\u5df2                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"4367689\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u4e3b<\/span> <span>\u8cc7\u6df1\u5927\u4f6c : gyy028012 <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             @tmackan <br \/>\u4ee3\u7801\u662f\u8fd9\u6837\u7684\uff1a<br \/>\uff08\u6211\u89c9\u5f97\u4e0d\u662f py \u4ee3\u7801\u7684\u95ee\u9898\uff0c\u56e0\u4e3a\u5176\u4ed6\u7684 SQL \u8bed\u53e5\u662f\u53ef\u4ee5\u8fd0\u884c\u7684\uff0c\u53ef\u80fd\u662f\u8fd9\u4e2a SQL \u91cc\u9762\u6709\u4e24\u4e2a\u5206\u53f7\u5bfc\u81f4\u7684\uff09<br \/>sql =&#8221;&#8221;&#8221;<br \/>SET @days := 10;<br \/>SELECT @days as &#8216;days&#8217;;<br \/>&#8220;&#8221;&#8221;<br \/>conn = pymysql.connect(host, port,user,password,database,charset=&#8221;utf8&#8243;)<br \/>cur = conn.cursor()<br \/>cur.execute(sql)<br \/>conn.commit()                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li>\n","protected":false},"excerpt":{"rendered":"<p>pymysql \u6267\u884c\u62a5\u9519\uff0c\u5927\u4f6c\u4eec\u5e2e&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\/210542"}],"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=210542"}],"version-history":[{"count":0,"href":"http:\/\/4563.org\/index.php?rest_route=\/wp\/v2\/posts\/210542\/revisions"}],"wp:attachment":[{"href":"http:\/\/4563.org\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=210542"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/4563.org\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=210542"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/4563.org\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=210542"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}