{"id":498,"date":"2017-02-11T21:22:14","date_gmt":"2017-02-11T13:22:14","guid":{"rendered":"http:\/\/www.rainweb.site\/?p=498"},"modified":"2023-08-07T20:57:29","modified_gmt":"2023-08-07T12:57:29","slug":"python-article47","status":"publish","type":"post","link":"http:\/\/rain1024.com\/index.php\/2017\/02\/11\/python-article47\/","title":{"rendered":"\u5173\u4e8ePython\u4e2d\u4f7f\u7528SQL\u8bed\u53e5\u8fdb\u884c\u6a21\u7cca\u67e5\u8be2"},"content":{"rendered":"<h2>\u4eca\u5929\u60f3\u5199\u4e2a\u811a\u672c\u67e5\u4e00\u4e0b\u6570\u636e\u5e93\u91cc\u7684\u4e00\u4e9b\u6570\u636e\uff0c\u4f46\u6709\u4e9b\u540d\u79f0\u6211\u53ea\u8bb0\u5f97\u4e00\u4e9b\uff0c\u4fbf\u60f3\u5230\u4f7f\u7528SQL\u8bed\u53e5\u4e2d\u7684\u6a21\u7cca\u67e5\u8be2\uff0c\u6b63\u5e38\u7684\u6a21\u7cca\u67e5\u8be2\u5e94\u8be5\u662f\u8fd9\u6837\u7684<\/h2>\n<pre><code>select * from tables where like %\u5173\u952e\u5b57%\n<\/code><\/pre>\n<h2>\u4f46\u662fPython\u5bf9%\u4f1a\u8f6c\u4e49\uff0c\u603b\u662f\u51fa\u9519\uff0c\u6539\u4e86\u597d\u591a\u6b21\uff0c\u6700\u540e\u53d1\u73b0\u4e0d\u7528\u5168\u90e8\u90fd\u5199\u51fa\u6765\uff0c\u5199\u6210\u4e0b\u9762\u8fd9\u6837\u5c31\u53ef\u4ee5\u4e86<\/h2>\n<pre><code>    select_name = raw_input()\n    domain_str = \"%\" + select_name + \"%\"\n    sql = \"\"\"select * from pass where site like %s \"\"\"\n    result = cur.execute(sql, (domain_str))\n    for line in cur.fetchmany(result):\n        print line[1]\n<\/code><\/pre>\n<h2>Python\u5bf9\u4e2d\u6587\u5404\u79cd\u62a5\u9519\uff0c\u5173\u4e8ePython\u8fde\u63a5\u6570\u636e\u5e93\u548c\u5bf9\u6570\u636e\u7684\u5176\u4ed6\u64cd\u4f5c\uff0c\u4ee5\u53ca\u62a5\u9519\u5904\u7406\uff0c\u53ef\u4ee5\u770b\u6211\u5176\u4ed6\u7684\u6587\u7ae0<\/h2>\n","protected":false},"excerpt":{"rendered":"<p>\u4eca\u5929\u60f3\u5199\u4e2a\u811a\u672c\u67e5\u4e00\u4e0b\u6570\u636e\u5e93\u91cc\u7684\u4e00\u4e9b\u6570\u636e\uff0c\u4f46\u6709\u4e9b\u540d\u79f0\u6211\u53ea\u8bb0\u5f97\u4e00\u4e9b\uff0c\u4fbf\u60f3\u5230\u4f7f\u7528SQL\u8bed\u53e5\u4e2d\u7684\u6a21\u7cca\u67e5\u8be2\uff0c\u6b63\u5e38\u7684\u6a21\u7cca\u67e5\u2026 <span class=\"read-more\"><a href=\"http:\/\/rain1024.com\/index.php\/2017\/02\/11\/python-article47\/\">Read More &raquo;<\/a><\/span><\/p>\n","protected":false},"author":1,"featured_media":499,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"aside","meta":{"footnotes":""},"categories":[15],"tags":[58,75],"class_list":["post-498","post","type-post","status-publish","format-aside","has-post-thumbnail","hentry","category-python","tag-python","tag-database","post_format-post-format-aside"],"_links":{"self":[{"href":"http:\/\/rain1024.com\/index.php\/wp-json\/wp\/v2\/posts\/498","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/rain1024.com\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/rain1024.com\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/rain1024.com\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/rain1024.com\/index.php\/wp-json\/wp\/v2\/comments?post=498"}],"version-history":[{"count":1,"href":"http:\/\/rain1024.com\/index.php\/wp-json\/wp\/v2\/posts\/498\/revisions"}],"predecessor-version":[{"id":1493,"href":"http:\/\/rain1024.com\/index.php\/wp-json\/wp\/v2\/posts\/498\/revisions\/1493"}],"wp:featuredmedia":[{"embeddable":true,"href":"http:\/\/rain1024.com\/index.php\/wp-json\/wp\/v2\/media\/499"}],"wp:attachment":[{"href":"http:\/\/rain1024.com\/index.php\/wp-json\/wp\/v2\/media?parent=498"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/rain1024.com\/index.php\/wp-json\/wp\/v2\/categories?post=498"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/rain1024.com\/index.php\/wp-json\/wp\/v2\/tags?post=498"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}