{"id":7497,"date":"2024-11-14T12:22:55","date_gmt":"2024-11-14T04:22:55","guid":{"rendered":"https:\/\/fwq.ai\/blog\/7497\/"},"modified":"2024-11-14T12:22:55","modified_gmt":"2024-11-14T04:22:55","slug":"python3%e7%a8%8b%e5%ba%8f%e6%8a%a5%e9%94%99err-sql%e5%a6%82%e4%bd%95%e8%a7%a3%e5%86%b3%ef%bc%9f","status":"publish","type":"post","link":"https:\/\/fwq.ai\/blog\/7497\/","title":{"rendered":"Python3\u7a0b\u5e8f\u62a5\u9519\u201cerr: + sql\u201d\u5982\u4f55\u89e3\u51b3\uff1f"},"content":{"rendered":"<p><img decoding=\"async\" src=\"https:\/\/img.php.cn\/upload\/article\/001\/246\/273\/173090163867978.jpg\" class=\"aligncenter\" title=\"Python3\u7a0b\u5e8f\u62a5\u9519\u201cerr: + sql\u201d\u5982\u4f55\u89e3\u51b3\uff1f\u63d2\u56fe\" alt=\"Python3\u7a0b\u5e8f\u62a5\u9519\u201cerr: + sql\u201d\u5982\u4f55\u89e3\u51b3\uff1f\u63d2\u56fe\" \/><\/p>\n<p><strong>3\u7a0b\u5e8f\u62a5\u9519\u201cerr: + sql\u201d\u5982\u4f55\u89e3\u51b3\uff1f<\/strong><\/p>\n<p>\u5728\u6267\u884c\u5982\u4e0b python \u4ee3\u7801\u65f6\uff0c\u9047\u5230\u4e86\u9519\u8bef\u201cerr: + sql\u201d\uff1a<\/p>\n<pre>def excute_sql_db(stratagy_id, city_id, app_name, total_price, over_flow_price, date_time):\n    sql = \"insert into over_flow_price(straragy_id,city_id,app_name,total_price,over_flow_price,time_stamp)values('%s','%s','%s','%s','%s','%s')\" % (\n        stratagy_id, city_id, app_name, total_price, over_flow_price, date_time)\n    try:\n        mycursor.execute(sql)\n        print('\u63d2\u5165\u6210\u529f')\n    except exception as e:\n        print('err: ' + sql)\n        print(e)<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p><strong>\u89e3\u51b3\u65b9\u6848\uff1a<\/strong><\/p>\n<p>\u5f15\u53d1\u6b64\u9519\u8bef\u7684\u539f\u56e0\u662f\uff0c\u5728 sql \u8bed\u53e5\u7684\u5b57\u7b26\u4e32\u683c\u5f0f\u5316\u8fc7\u7a0b\u4e2d\uff0c\u5c06 sql \u5b57\u7b26\u4e32\u548c\u9519\u8bef\u4fe1\u606f\u8fdb\u884c\u62fc\u63a5\uff0c\u800c\u4e0d\u662f\u5c06\u9519\u8bef\u4fe1\u606f\u4f5c\u4e3a\u5f02\u5e38\u4fe1\u606f\u62a5\u544a\u3002\u6b63\u786e\u7684\u65b9\u6cd5\u662f\uff0c\u5c06\u9519\u8bef\u4fe1\u606f\u4f5c\u4e3a\u5f02\u5e38\u629b\u51fa\uff0c\u800c\u4e0d\u662f\u6253\u5370\u5728\u63a7\u5236\u53f0\u4e0a\u3002<\/p>\n<p><span>\u7acb\u5373\u5b66\u4e60<\/span>\u201c\u201d\uff1b<\/p>\n<p>\u4fee\u6b63\u8fc7\u7684\u4ee3\u7801\u5982\u4e0b\uff1a<\/p>\n<pre>def excute_sql_db(stratagy_id, city_id, app_name, total_price, over_flow_price, date_time):\n    sql = \"INSERT INTO over_flow_price(straragy_id,city_id,app_name,total_price,over_flow_price,time_stamp)VALUES('%s','%s','%s','%s','%s','%s')\" % (\n        stratagy_id, city_id, app_name, total_price, over_flow_price, date_time)\n    try:\n        mycursor.execute(sql)\n        print('\u63d2\u5165\u6210\u529f')\n    except Exception as e:\n        raise Exception('err: ' + sql)<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p>\u4fee\u6b63\u540e\u7684\u4ee3\u7801\u5c06\u5f02\u5e38\u4fe1\u606f\u4f5c\u4e3a\u5f02\u5e38\u629b\u51fa\uff0c\u800c\u4e0d\u662f\u6253\u5370\u5728\u63a7\u5236\u53f0\u4e0a\uff0c\u4ece\u800c\u6b63\u786e\u5904\u7406\u9519\u8bef\u3002<\/p>\n<p>\u4ee5\u4e0a\u5c31\u662fPython3\u7a0b\u5e8f\u62a5\u9519\u201cerr: + sql\u201d\u5982\u4f55\u89e3\u51b3\uff1f\u7684\u8be6\u7ec6\u5185\u5bb9\uff0c\u66f4\u591a\u8bf7\u5173\u6ce8\u7c73\u4e91\u7f51\u5176\u5b83\u76f8\u5173\u6587\u7ae0\uff01<\/p>\n","protected":false},"excerpt":{"rendered":"<p>3\u7a0b\u5e8f\u62a5\u9519\u201cerr: + sql\u201d\u5982\u4f55\u89e3\u51b3\uff1f \u5728\u6267\u884c\u5982\u4e0b python \u4ee3\u7801\u65f6\uff0c\u9047\u5230\u4e86\u9519\u8bef\u201cerr: + sql\u201d\uff1a def excute_sql_db(stratagy_id, city_id, app_name, total_price, over_flow_price, date_time): sql = &#8220;insert into over_flow_price(straragy_id,city_id,app_name,total_price,over_flow_price,time_stamp)values(&#8216;%s&#8217;,&#8217;%s&#8217;,&#8217;%s&#8217;,&#8217;%s&#8217;,&#8217;%s&#8217;,&#8217;%s&#8217;)&#8221; % ( stratagy_id, city_id, app_name, total_price, over_flow_price, date_time) try: mycursor.execute(sql) print(&#8216;\u63d2\u5165\u6210\u529f&#8217;) except exception as e: print(&#8216;err: &#8216; + sql) print(e) \u767b\u5f55\u540e\u590d\u5236 \u89e3\u51b3\u65b9\u6848\uff1a \u5f15\u53d1\u6b64\u9519\u8bef\u7684\u539f\u56e0\u662f\uff0c\u5728 sql \u8bed\u53e5\u7684\u5b57\u7b26\u4e32\u683c\u5f0f\u5316\u8fc7\u7a0b\u4e2d\uff0c\u5c06 sql \u5b57\u7b26\u4e32\u548c\u9519\u8bef\u4fe1\u606f\u8fdb\u884c\u62fc\u63a5\uff0c\u800c\u4e0d\u662f\u5c06\u9519\u8bef\u4fe1\u606f\u4f5c\u4e3a\u5f02\u5e38\u4fe1\u606f\u62a5\u544a\u3002\u6b63\u786e\u7684\u65b9\u6cd5\u662f\uff0c\u5c06\u9519\u8bef\u4fe1\u606f\u4f5c\u4e3a\u5f02\u5e38\u629b\u51fa\uff0c\u800c\u4e0d\u662f\u6253\u5370\u5728\u63a7\u5236\u53f0\u4e0a\u3002 \u7acb\u5373\u5b66\u4e60\u201c\u201d\uff1b \u4fee\u6b63\u8fc7\u7684\u4ee3\u7801\u5982\u4e0b\uff1a def excute_sql_db(stratagy_id, city_id, app_name, total_price, over_flow_price, [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[16],"tags":[],"class_list":["post-7497","post","type-post","status-publish","format-standard","hentry","category-16"],"_links":{"self":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/7497","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/comments?post=7497"}],"version-history":[{"count":0,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/7497\/revisions"}],"wp:attachment":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/media?parent=7497"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/categories?post=7497"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/tags?post=7497"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}