{"id":702,"date":"2021-11-21T03:37:00","date_gmt":"2021-11-21T03:37:00","guid":{"rendered":"https:\/\/262235.xyz\/?p=702"},"modified":"2021-11-21T03:37:00","modified_gmt":"2021-11-21T03:37:00","slug":"702","status":"publish","type":"post","link":"https:\/\/lyvba.com\/index.php\/2021\/11\/21\/702\/","title":{"rendered":"WordPress\u548cTypecho\u6587\u7ae0\u5185\u5bb9\u6279\u91cf\u66ff\u6362\u6587\u5b57\u7684\u65b9\u6cd5"},"content":{"rendered":"<h2>WordPress\u548cTypecho\u6587\u7ae0\u5185\u5bb9\u6279\u91cf\u66ff\u6362\u6587\u5b57\u7684\u65b9\u6cd5<\/h2>\n<p><img decoding=\"async\" src=\"https:\/\/lyvba.com\/wp-content\/uploads\/2021\/11\/3415567265.webp\" alt=\"sql.webp\" title=\"sql.webp\"><\/p>\n<h2>WordPress \u5b58\u653e\u6587\u7ae0\u7684\u6570\u636e\u8868\u540d <code>wp_posts<\/code> \uff0c\u5b57\u6bb5\u540d\u79f0\u4e3a <code>post_content<\/code><\/h2>\n<h3>WordPress\u6570\u636e\u5e93\u66ff\u6362SQL\u8bed\u53e5<\/h3>\n<pre><code>UPDATE wp_posts SET post_content = replace(post_content,'\u65e7\u8bcd\u8bed','\u65b0\u8bcd\u8bed');\n\nUPDATE wp_posts SET post_content = replace(post_content,'https:\/\/lyvba.com','https:\/\/us.lyvba.com');\n\/* \u53d7\u5f71\u54cd\u8bb0\u5f55\u884c\u6570: 4  \u5df2\u627e\u5230\u8bb0\u5f55\u884c: 0  \u8b66\u544a: 0  \u6301\u7eed\u65f6\u95f4 1 \u67e5\u8be2: 0.015 \u79d2. *\/<\/code><\/pre>\n<ul>\n<li>\n<p>\u76f8\u5173\u6587\u7ae0:<a href=\"https:\/\/lyvba.com\/index.php\/archives\/711\/\">WordPress\u7f51\u7ad9\u66f4\u6539\u57df\u540d\u540e\u6587\u7ae0\u53ef\u4ee5\u4f1a\u51fa\u73b0guid\u95ee\u9898\u89e3\u51b3\u65b9\u6cd5<\/a><\/p>\n<h3>\u4f7f\u7528 HeidiSQL \u53ef\u4ee5\u8fde MYSQL\u6570\u636e\u5e93\u6216\u8005SQLite\u6570\u636e\u5e93\u6587\u4ef6\uff0c\u4f7f\u7528\u67e5\u8be2\u547d\u4ee4\u6267\u884c <code>UPDATE<\/code> \u8bed\u53e5<\/h3>\n<p><img decoding=\"async\" src=\"https:\/\/lyvba.com\/wp-content\/uploads\/2021\/11\/2801957959.webp\" alt=\"HeidiSQL.webp\" title=\"HeidiSQL.webp\"><\/p>\n<\/li>\n<\/ul>\n<h2>Typecho \u5b58\u653e\u6587\u7ae0\u7684\u6570\u636e\u8868\u540d <code>typecho_contents<\/code> \uff0c\u5b57\u6bb5\u540d\u79f0\u4e3a <code>text<\/code><\/h2>\n<h3>Typecho\u6570\u636e\u5e93\u66ff\u6362SQL\u8bed\u53e5<\/h3>\n<pre><code>UPDATE typecho_contents SET text = replace(text,'\u65e7\u8bcd\u8bed','\u65b0\u8bcd\u8bed');\n\nUPDATE typecho_contents SET text = replace(text,'https:\/\/lyvba.com','https:\/\/us.lyvba.com');\n\/* \u53d7\u5f71\u54cd\u8bb0\u5f55\u884c\u6570: 584  \u5df2\u627e\u5230\u8bb0\u5f55\u884c: 0  \u8b66\u544a: 0  \u6301\u7eed\u65f6\u95f4 1 \u67e5\u8be2: 0.000 \u79d2. (+ 0.031 \u79d2. \u7f51\u7edc) *\/<\/code><\/pre>\n<h3>Python\u811a\u672c <code>sqlite3_sql_replace.py<\/code> \u7528\u6765\u6267\u884c\u7b80\u5355\u7684SQL\u8bed\u53e5\u4e5f\u5f88\u65b9\u4fbf<\/h3>\n<pre><code>import sqlite3\nconn = sqlite3.connect('example.db')\n\n# \u521b\u5efa\u4e00\u4e2a Cursor \u6e38\u6807\u5bf9\u8c61\uff0c\u7136\u540e\u8c03\u7528\u5b83\u7684 execute() \u65b9\u6cd5\u6765\u6267\u884c SQL \u8bed\u53e5\uff1a\nc = conn.cursor()\n\n# Typecho SQLite3 \u6570\u636e\u5e93\u66ff\u6362SQL\u8bed\u53e5\nc.execute(\"UPDATE typecho_contents SET text = replace(text,'https:\/\/lyvba.com','https:\/\/us.lyvba.com')\")\n\n# Save (commit) the changes  \u548c \u5173\u95ed\u6570\u636e\u5e93\u8fde\u63a5\nconn.commit()\nconn.close()<\/code><\/pre>\n<ul>\n<li>\n<p>SELECT \u67e5\u8be2\u6587\u7ae0\u4fe1\u606f<\/p>\n<pre><code># \u67e5\u8be2\u6587\u7ae0\u6307\u5b9a\u7c7b\u578bpost\uff0c\u6309cid\u53cd\u5e8f\uff0c\u9650\u5b9a5\u884c\nfor row in c.execute('SELECT * FROM typecho_contents where type=\"post\" ORDER BY cid desc  LIMIT 5'):\n  print(row)\n\n# \u67e5\u8be2\u6587\u7ae0\uff0c\u6309text\u5e8f\uff0c\u9650\u5b9a20\u884c\nfor row in c.execute('SELECT * FROM typecho_contents ORDER BY text LIMIT 20'):\n  print(row[0],row[1])<\/code><\/pre>\n<\/li>\n<\/ul>\n","protected":false},"excerpt":{"rendered":"<p>WordPress\u548cTypecho\u6587\u7ae0\u5185\u5bb9\u6279\u91cf\u66ff\u6362\u6587\u5b57\u7684\u65b9\u6cd5 WordPress \u5b58\u653e\u6587\u7ae0\u7684\u6570\u636e\u8868\u540d [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[12],"tags":[59],"class_list":["post-702","post","type-post","status-publish","format-standard","hentry","category-learn","tag-sql"],"_links":{"self":[{"href":"https:\/\/lyvba.com\/index.php\/wp-json\/wp\/v2\/posts\/702","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/lyvba.com\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/lyvba.com\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/lyvba.com\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/lyvba.com\/index.php\/wp-json\/wp\/v2\/comments?post=702"}],"version-history":[{"count":0,"href":"https:\/\/lyvba.com\/index.php\/wp-json\/wp\/v2\/posts\/702\/revisions"}],"wp:attachment":[{"href":"https:\/\/lyvba.com\/index.php\/wp-json\/wp\/v2\/media?parent=702"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/lyvba.com\/index.php\/wp-json\/wp\/v2\/categories?post=702"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/lyvba.com\/index.php\/wp-json\/wp\/v2\/tags?post=702"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}