{"id":1136909,"date":"2025-01-08T21:41:34","date_gmt":"2025-01-08T13:41:34","guid":{"rendered":"https:\/\/docs.pingcode.com\/ask\/ask-ask\/1136909.html"},"modified":"2025-01-08T21:41:38","modified_gmt":"2025-01-08T13:41:38","slug":"%e5%a6%82%e4%bd%95%e7%94%a8python%e5%81%9a%e4%b8%80%e4%b8%aa%e6%95%b0%e6%8d%ae%e5%ba%93","status":"publish","type":"post","link":"https:\/\/docs.pingcode.com\/ask\/1136909.html","title":{"rendered":"\u5982\u4f55\u7528python\u505a\u4e00\u4e2a\u6570\u636e\u5e93"},"content":{"rendered":"<p style=\"text-align:center;\" ><img decoding=\"async\" src=\"https:\/\/cdn-kb.worktile.com\/kb\/wp-content\/uploads\/2024\/04\/25100842\/8ef6f8ee-5367-4a11-a52d-c16f00da3ae9.webp\" alt=\"\u5982\u4f55\u7528python\u505a\u4e00\u4e2a\u6570\u636e\u5e93\" \/><\/p>\n<p><p> <strong>\u7528Python\u521b\u5efa\u6570\u636e\u5e93\u7684\u65b9\u6cd5\u5305\u62ec\uff1a\u9009\u62e9\u6570\u636e\u5e93\u7ba1\u7406\u7cfb\u7edf\u3001\u5b89\u88c5\u5fc5\u8981\u7684\u8f6f\u4ef6\u548c\u5e93\u3001\u8fde\u63a5\u6570\u636e\u5e93\u3001\u521b\u5efa\u6570\u636e\u5e93\u548c\u8868\u3001\u6267\u884cCRUD\u64cd\u4f5c\u3002<\/strong> \u5728\u8fd9\u7bc7\u6587\u7ae0\u4e2d\uff0c\u6211\u4eec\u5c06\u8be6\u7ec6\u63a2\u8ba8\u8fd9\u4e9b\u6b65\u9aa4\uff0c\u5e76\u4e3e\u4f8b\u8bf4\u660e\u5982\u4f55\u5728\u5b9e\u9645\u9879\u76ee\u4e2d\u5e94\u7528\u8fd9\u4e9b\u65b9\u6cd5\u3002\u7279\u522b\u662f\uff0c\u6211\u4eec\u5c06\u6df1\u5165\u8ba8\u8bba\u5982\u4f55\u9009\u62e9\u9002\u5408\u7684\u6570\u636e\u5e93\u7ba1\u7406\u7cfb\u7edf\uff0c\u5e76\u5c55\u793a\u4e00\u4e9b\u6700\u4f73\u5b9e\u8df5\u3002<\/p>\n<\/p>\n<p><h3>\u4e00\u3001\u9009\u62e9\u6570\u636e\u5e93\u7ba1\u7406\u7cfb\u7edf<\/h3>\n<\/p>\n<p><p>\u9009\u62e9\u5408\u9002\u7684\u6570\u636e\u5e93\u7ba1\u7406\u7cfb\u7edf\uff08DBMS\uff09\u662f\u521b\u5efa\u6570\u636e\u5e93\u7684\u7b2c\u4e00\u6b65\u3002\u5728Python\u4e2d\uff0c\u5e38\u89c1\u7684DBMS\u5305\u62ecSQLite\u3001MySQL\u3001PostgreSQL\u548cMongoDB\u3002\u6bcf\u79cdDBMS\u90fd\u6709\u5176\u72ec\u7279\u7684\u4f18\u70b9\u548c\u9002\u7528\u573a\u666f\u3002<\/p>\n<\/p>\n<p><h4>1.1 SQLite<\/h4>\n<\/p>\n<p><p>SQLite\u662f\u4e00\u79cd\u5d4c\u5165\u5f0f\u6570\u636e\u5e93\uff0c\u9002\u7528\u4e8e\u5c0f\u578b\u5230\u4e2d\u578b\u5e94\u7528\u3002\u5b83\u7684\u4f18\u70b9\u5305\u62ec\uff1a\u65e0\u9700\u5355\u72ec\u7684\u6570\u636e\u5e93\u670d\u52a1\u5668\u3001\u8f7b\u91cf\u7ea7\u548c\u6613\u4e8e\u90e8\u7f72\u3002SQLite\u975e\u5e38\u9002\u5408\u684c\u9762\u5e94\u7528\u3001\u5c0f\u578bWeb\u5e94\u7528\u548c\u79fb\u52a8\u5e94\u7528\u3002<\/p>\n<\/p>\n<p><h4>1.2 MySQL<\/h4>\n<\/p>\n<p><p>MySQL\u662f\u4e00\u79cd\u6d41\u884c\u7684\u5173\u7cfb\u578b\u6570\u636e\u5e93\u7ba1\u7406\u7cfb\u7edf\uff0c\u9002\u7528\u4e8e\u4e2d\u578b\u5230\u5927\u578b\u5e94\u7528\u3002\u5b83\u7684\u4f18\u70b9\u5305\u62ec\uff1a\u9ad8\u6027\u80fd\u3001\u5f3a\u5927\u7684\u793e\u533a\u652f\u6301\u548c\u5e7f\u6cdb\u7684\u5de5\u5177\u751f\u6001\u7cfb\u7edf\u3002MySQL\u975e\u5e38\u9002\u5408Web\u5e94\u7528\u548c\u4f01\u4e1a\u7ea7\u5e94\u7528\u3002<\/p>\n<\/p>\n<p><h4>1.3 PostgreSQL<\/h4>\n<\/p>\n<p><p>PostgreSQL\u662f\u4e00\u79cd\u529f\u80fd\u5f3a\u5927\u7684\u5f00\u6e90\u5173\u7cfb\u578b\u6570\u636e\u5e93\u7ba1\u7406\u7cfb\u7edf\uff0c\u9002\u7528\u4e8e\u5927\u578b\u5e94\u7528\u3002\u5b83\u7684\u4f18\u70b9\u5305\u62ec\uff1a\u652f\u6301\u590d\u6742\u67e5\u8be2\u3001\u4e8b\u52a1\u5904\u7406\u548c\u6269\u5c55\u6027\u3002PostgreSQL\u975e\u5e38\u9002\u5408\u9700\u8981\u9ad8\u6027\u80fd\u548c\u590d\u6742\u6570\u636e\u5904\u7406\u7684\u5e94\u7528\u3002<\/p>\n<\/p>\n<p><h4>1.4 MongoDB<\/h4>\n<\/p>\n<p><p>MongoDB\u662f\u4e00\u79cdNoSQL\u6570\u636e\u5e93\uff0c\u9002\u7528\u4e8e\u5904\u7406\u975e\u7ed3\u6784\u5316\u6570\u636e\u7684\u5e94\u7528\u3002\u5b83\u7684\u4f18\u70b9\u5305\u62ec\uff1a\u7075\u6d3b\u7684\u6570\u636e\u6a21\u578b\u3001\u9ad8\u6027\u80fd\u548c\u9ad8\u6269\u5c55\u6027\u3002MongoDB\u975e\u5e38\u9002\u5408\u5927\u6570\u636e\u5e94\u7528\u548c\u5b9e\u65f6\u5206\u6790\u3002<\/p>\n<\/p>\n<p><h3>\u4e8c\u3001\u5b89\u88c5\u5fc5\u8981\u7684\u8f6f\u4ef6\u548c\u5e93<\/h3>\n<\/p>\n<p><p>\u6839\u636e\u6240\u9009\u62e9\u7684DBMS\uff0c\u5b89\u88c5\u76f8\u5e94\u7684\u8f6f\u4ef6\u548c\u5e93\u3002\u4ee5\u4e0b\u662f\u6bcf\u79cdDBMS\u7684\u5b89\u88c5\u6307\u5357\u3002<\/p>\n<\/p>\n<p><h4>2.1 \u5b89\u88c5SQLite<\/h4>\n<\/p>\n<p><p>SQLite\u65e0\u9700\u5b89\u88c5\u4efb\u4f55\u670d\u52a1\u5668\u8f6f\u4ef6\u3002\u53ea\u9700\u5b89\u88c5Python\u6807\u51c6\u5e93\u4e2d\u7684sqlite3\u6a21\u5757\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-bash\">pip install pysqlite3<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><h4>2.2 \u5b89\u88c5MySQL<\/h4>\n<\/p>\n<p><p>\u9996\u5148\uff0c\u5b89\u88c5MySQL\u670d\u52a1\u5668\u548c\u5ba2\u6237\u7aef\u5de5\u5177\u3002\u7136\u540e\uff0c\u5b89\u88c5Python\u7684MySQL\u8fde\u63a5\u5e93\uff0c\u4f8b\u5982mysql-connector-python\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-bash\">pip install mysql-connector-python<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><h4>2.3 \u5b89\u88c5PostgreSQL<\/h4>\n<\/p>\n<p><p>\u9996\u5148\uff0c\u5b89\u88c5PostgreSQL\u670d\u52a1\u5668\u548c\u5ba2\u6237\u7aef\u5de5\u5177\u3002\u7136\u540e\uff0c\u5b89\u88c5Python\u7684PostgreSQL\u8fde\u63a5\u5e93\uff0c\u4f8b\u5982psycopg2\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-bash\">pip install psycopg2<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><h4>2.4 \u5b89\u88c5MongoDB<\/h4>\n<\/p>\n<p><p>\u9996\u5148\uff0c\u5b89\u88c5MongoDB\u670d\u52a1\u5668\u3002\u7136\u540e\uff0c\u5b89\u88c5Python\u7684MongoDB\u8fde\u63a5\u5e93\uff0c\u4f8b\u5982pymongo\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-bash\">pip install pymongo<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><h3>\u4e09\u3001\u8fde\u63a5\u6570\u636e\u5e93<\/h3>\n<\/p>\n<p><p>\u4e0b\u4e00\u6b65\u662f\u4f7f\u7528Python\u4ee3\u7801\u8fde\u63a5\u5230\u6570\u636e\u5e93\u3002\u4e0d\u540c\u7684DBMS\u6709\u4e0d\u540c\u7684\u8fde\u63a5\u65b9\u6cd5\uff0c\u4ee5\u4e0b\u662f\u5e38\u89c1\u7684\u8fde\u63a5\u793a\u4f8b\u3002<\/p>\n<\/p>\n<p><h4>3.1 \u8fde\u63a5SQLite<\/h4>\n<\/p>\n<p><pre><code class=\"language-python\">import sqlite3<\/p>\n<h2><strong>\u8fde\u63a5\u5230SQLite\u6570\u636e\u5e93\uff08\u5982\u679c\u6570\u636e\u5e93\u4e0d\u5b58\u5728\uff0c\u4f1a\u81ea\u52a8\u521b\u5efa\uff09<\/strong><\/h2>\n<p>conn = sqlite3.connect(&#39;example.db&#39;)<\/p>\n<p>cursor = conn.cursor()<\/p>\n<h2><strong>\u6267\u884cSQL\u67e5\u8be2<\/strong><\/h2>\n<p>cursor.execute(&quot;SELECT sqlite_version();&quot;)<\/p>\n<p>print(cursor.fetchone())<\/p>\n<h2><strong>\u5173\u95ed\u8fde\u63a5<\/strong><\/h2>\n<p>conn.close()<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><h4>3.2 \u8fde\u63a5MySQL<\/h4>\n<\/p>\n<p><pre><code class=\"language-python\">import mysql.connector<\/p>\n<h2><strong>\u8fde\u63a5\u5230MySQL\u6570\u636e\u5e93<\/strong><\/h2>\n<p>conn = mysql.connector.connect(<\/p>\n<p>    host=&quot;localhost&quot;,<\/p>\n<p>    user=&quot;yourusername&quot;,<\/p>\n<p>    password=&quot;yourpassword&quot;,<\/p>\n<p>    database=&quot;yourdatabase&quot;<\/p>\n<p>)<\/p>\n<p>cursor = conn.cursor()<\/p>\n<h2><strong>\u6267\u884cSQL\u67e5\u8be2<\/strong><\/h2>\n<p>cursor.execute(&quot;SELECT VERSION();&quot;)<\/p>\n<p>print(cursor.fetchone())<\/p>\n<h2><strong>\u5173\u95ed\u8fde\u63a5<\/strong><\/h2>\n<p>conn.close()<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><h4>3.3 \u8fde\u63a5PostgreSQL<\/h4>\n<\/p>\n<p><pre><code class=\"language-python\">import psycopg2<\/p>\n<h2><strong>\u8fde\u63a5\u5230PostgreSQL\u6570\u636e\u5e93<\/strong><\/h2>\n<p>conn = psycopg2.connect(<\/p>\n<p>    host=&quot;localhost&quot;,<\/p>\n<p>    database=&quot;yourdatabase&quot;,<\/p>\n<p>    user=&quot;yourusername&quot;,<\/p>\n<p>    password=&quot;yourpassword&quot;<\/p>\n<p>)<\/p>\n<p>cursor = conn.cursor()<\/p>\n<h2><strong>\u6267\u884cSQL\u67e5\u8be2<\/strong><\/h2>\n<p>cursor.execute(&quot;SELECT version();&quot;)<\/p>\n<p>print(cursor.fetchone())<\/p>\n<h2><strong>\u5173\u95ed\u8fde\u63a5<\/strong><\/h2>\n<p>conn.close()<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><h4>3.4 \u8fde\u63a5MongoDB<\/h4>\n<\/p>\n<p><pre><code class=\"language-python\">from pymongo import MongoClient<\/p>\n<h2><strong>\u8fde\u63a5\u5230MongoDB<\/strong><\/h2>\n<p>client = MongoClient(&#39;localhost&#39;, 27017)<\/p>\n<p>db = client.yourdatabase<\/p>\n<h2><strong>\u6267\u884c\u67e5\u8be2<\/strong><\/h2>\n<p>print(db.collection_names())<\/p>\n<h2><strong>\u5173\u95ed\u8fde\u63a5<\/strong><\/h2>\n<p>client.close()<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><h3>\u56db\u3001\u521b\u5efa\u6570\u636e\u5e93\u548c\u8868<\/h3>\n<\/p>\n<p><p>\u63a5\u4e0b\u6765\uff0c\u6211\u4eec\u5c06\u8ba8\u8bba\u5982\u4f55\u4f7f\u7528Python\u4ee3\u7801\u5728\u4e0d\u540c\u7684DBMS\u4e2d\u521b\u5efa\u6570\u636e\u5e93\u548c\u8868\u3002<\/p>\n<\/p>\n<p><h4>4.1 \u521b\u5efaSQLite\u6570\u636e\u5e93\u548c\u8868<\/h4>\n<\/p>\n<p><p>SQLite\u4e0d\u9700\u8981\u663e\u5f0f\u5730\u521b\u5efa\u6570\u636e\u5e93\uff0c\u53ea\u9700\u76f4\u63a5\u521b\u5efa\u8868\u5373\u53ef\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">import sqlite3<\/p>\n<p>conn = sqlite3.connect(&#39;example.db&#39;)<\/p>\n<p>cursor = conn.cursor()<\/p>\n<h2><strong>\u521b\u5efa\u8868<\/strong><\/h2>\n<p>cursor.execute(&#39;&#39;&#39;<\/p>\n<p>CREATE TABLE users (<\/p>\n<p>    id INTEGER PRIMARY KEY,<\/p>\n<p>    name TEXT NOT NULL,<\/p>\n<p>    age INTEGER NOT NULL<\/p>\n<p>)<\/p>\n<p>&#39;&#39;&#39;)<\/p>\n<h2><strong>\u63d0\u4ea4\u4e8b\u52a1<\/strong><\/h2>\n<p>conn.commit()<\/p>\n<p>conn.close()<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><h4>4.2 \u521b\u5efaMySQL\u6570\u636e\u5e93\u548c\u8868<\/h4>\n<\/p>\n<p><pre><code class=\"language-python\">import mysql.connector<\/p>\n<p>conn = mysql.connector.connect(<\/p>\n<p>    host=&quot;localhost&quot;,<\/p>\n<p>    user=&quot;yourusername&quot;,<\/p>\n<p>    password=&quot;yourpassword&quot;<\/p>\n<p>)<\/p>\n<p>cursor = conn.cursor()<\/p>\n<h2><strong>\u521b\u5efa\u6570\u636e\u5e93<\/strong><\/h2>\n<p>cursor.execute(&quot;CREATE DATABASE IF NOT EXISTS yourdatabase&quot;)<\/p>\n<h2><strong>\u9009\u62e9\u6570\u636e\u5e93<\/strong><\/h2>\n<p>conn.database = &#39;yourdatabase&#39;<\/p>\n<h2><strong>\u521b\u5efa\u8868<\/strong><\/h2>\n<p>cursor.execute(&#39;&#39;&#39;<\/p>\n<p>CREATE TABLE users (<\/p>\n<p>    id INT AUTO_INCREMENT PRIMARY KEY,<\/p>\n<p>    name VARCHAR(255) NOT NULL,<\/p>\n<p>    age INT NOT NULL<\/p>\n<p>)<\/p>\n<p>&#39;&#39;&#39;)<\/p>\n<h2><strong>\u63d0\u4ea4\u4e8b\u52a1<\/strong><\/h2>\n<p>conn.commit()<\/p>\n<p>conn.close()<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><h4>4.3 \u521b\u5efaPostgreSQL\u6570\u636e\u5e93\u548c\u8868<\/h4>\n<\/p>\n<p><pre><code class=\"language-python\">import psycopg2<\/p>\n<p>conn = psycopg2.connect(<\/p>\n<p>    host=&quot;localhost&quot;,<\/p>\n<p>    user=&quot;yourusername&quot;,<\/p>\n<p>    password=&quot;yourpassword&quot;<\/p>\n<p>)<\/p>\n<p>cursor = conn.cursor()<\/p>\n<h2><strong>\u521b\u5efa\u6570\u636e\u5e93<\/strong><\/h2>\n<p>cursor.execute(&quot;CREATE DATABASE yourdatabase&quot;)<\/p>\n<h2><strong>\u5173\u95ed\u8fde\u63a5\u5e76\u91cd\u65b0\u8fde\u63a5\u5230\u65b0\u6570\u636e\u5e93<\/strong><\/h2>\n<p>conn.close()<\/p>\n<p>conn = psycopg2.connect(<\/p>\n<p>    host=&quot;localhost&quot;,<\/p>\n<p>    database=&quot;yourdatabase&quot;,<\/p>\n<p>    user=&quot;yourusername&quot;,<\/p>\n<p>    password=&quot;yourpassword&quot;<\/p>\n<p>)<\/p>\n<p>cursor = conn.cursor()<\/p>\n<h2><strong>\u521b\u5efa\u8868<\/strong><\/h2>\n<p>cursor.execute(&#39;&#39;&#39;<\/p>\n<p>CREATE TABLE users (<\/p>\n<p>    id SERIAL PRIMARY KEY,<\/p>\n<p>    name VARCHAR(255) NOT NULL,<\/p>\n<p>    age INT NOT NULL<\/p>\n<p>)<\/p>\n<p>&#39;&#39;&#39;)<\/p>\n<h2><strong>\u63d0\u4ea4\u4e8b\u52a1<\/strong><\/h2>\n<p>conn.commit()<\/p>\n<p>conn.close()<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><h4>4.4 \u521b\u5efaMongoDB\u6570\u636e\u5e93\u548c\u96c6\u5408<\/h4>\n<\/p>\n<p><pre><code class=\"language-python\">from pymongo import MongoClient<\/p>\n<p>client = MongoClient(&#39;localhost&#39;, 27017)<\/p>\n<p>db = client.yourdatabase<\/p>\n<h2><strong>\u521b\u5efa\u96c6\u5408\uff08\u8868\uff09<\/strong><\/h2>\n<p>db.create_collection(&quot;users&quot;)<\/p>\n<h2><strong>\u63d2\u5165\u6587\u6863<\/strong><\/h2>\n<p>db.users.insert_one({&quot;name&quot;: &quot;John Doe&quot;, &quot;age&quot;: 30})<\/p>\n<h2><strong>\u5173\u95ed\u8fde\u63a5<\/strong><\/h2>\n<p>client.close()<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><h3>\u4e94\u3001\u6267\u884cCRUD\u64cd\u4f5c<\/h3>\n<\/p>\n<p><p>CRUD\u64cd\u4f5c\u5305\u62ec\u521b\u5efa\uff08Create\uff09\u3001\u8bfb\u53d6\uff08Read\uff09\u3001\u66f4\u65b0\uff08Update\uff09\u548c\u5220\u9664\uff08Delete\uff09\u6570\u636e\u3002\u5728\u8fd9\u4e00\u8282\u4e2d\uff0c\u6211\u4eec\u5c06\u5c55\u793a\u5982\u4f55\u5728\u4e0d\u540c\u7684DBMS\u4e2d\u6267\u884c\u8fd9\u4e9b\u64cd\u4f5c\u3002<\/p>\n<\/p>\n<p><h4>5.1 SQLite<\/h4>\n<\/p>\n<p><h5>\u521b\u5efa\u6570\u636e<\/h5>\n<\/p>\n<p><pre><code class=\"language-python\">import sqlite3<\/p>\n<p>conn = sqlite3.connect(&#39;example.db&#39;)<\/p>\n<p>cursor = conn.cursor()<\/p>\n<h2><strong>\u63d2\u5165\u6570\u636e<\/strong><\/h2>\n<p>cursor.execute(&#39;&#39;&#39;<\/p>\n<p>INSERT INTO users (name, age) VALUES (?, ?)<\/p>\n<p>&#39;&#39;&#39;, (&quot;John Doe&quot;, 30))<\/p>\n<h2><strong>\u63d0\u4ea4\u4e8b\u52a1<\/strong><\/h2>\n<p>conn.commit()<\/p>\n<p>conn.close()<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><h5>\u8bfb\u53d6\u6570\u636e<\/h5>\n<\/p>\n<p><pre><code class=\"language-python\">conn = sqlite3.connect(&#39;example.db&#39;)<\/p>\n<p>cursor = conn.cursor()<\/p>\n<h2><strong>\u67e5\u8be2\u6570\u636e<\/strong><\/h2>\n<p>cursor.execute(&#39;&#39;&#39;<\/p>\n<p>SELECT * FROM users<\/p>\n<p>&#39;&#39;&#39;)<\/p>\n<p>for row in cursor.fetchall():<\/p>\n<p>    print(row)<\/p>\n<p>conn.close()<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><h5>\u66f4\u65b0\u6570\u636e<\/h5>\n<\/p>\n<p><pre><code class=\"language-python\">conn = sqlite3.connect(&#39;example.db&#39;)<\/p>\n<p>cursor = conn.cursor()<\/p>\n<h2><strong>\u66f4\u65b0\u6570\u636e<\/strong><\/h2>\n<p>cursor.execute(&#39;&#39;&#39;<\/p>\n<p>UPDATE users SET age = ? WHERE name = ?<\/p>\n<p>&#39;&#39;&#39;, (31, &quot;John Doe&quot;))<\/p>\n<h2><strong>\u63d0\u4ea4\u4e8b\u52a1<\/strong><\/h2>\n<p>conn.commit()<\/p>\n<p>conn.close()<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><h5>\u5220\u9664\u6570\u636e<\/h5>\n<\/p>\n<p><pre><code class=\"language-python\">conn = sqlite3.connect(&#39;example.db&#39;)<\/p>\n<p>cursor = conn.cursor()<\/p>\n<h2><strong>\u5220\u9664\u6570\u636e<\/strong><\/h2>\n<p>cursor.execute(&#39;&#39;&#39;<\/p>\n<p>DELETE FROM users WHERE name = ?<\/p>\n<p>&#39;&#39;&#39;, (&quot;John Doe&quot;,))<\/p>\n<h2><strong>\u63d0\u4ea4\u4e8b\u52a1<\/strong><\/h2>\n<p>conn.commit()<\/p>\n<p>conn.close()<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><h4>5.2 MySQL<\/h4>\n<\/p>\n<p><h5>\u521b\u5efa\u6570\u636e<\/h5>\n<\/p>\n<p><pre><code class=\"language-python\">import mysql.connector<\/p>\n<p>conn = mysql.connector.connect(<\/p>\n<p>    host=&quot;localhost&quot;,<\/p>\n<p>    user=&quot;yourusername&quot;,<\/p>\n<p>    password=&quot;yourpassword&quot;,<\/p>\n<p>    database=&quot;yourdatabase&quot;<\/p>\n<p>)<\/p>\n<p>cursor = conn.cursor()<\/p>\n<h2><strong>\u63d2\u5165\u6570\u636e<\/strong><\/h2>\n<p>cursor.execute(&#39;&#39;&#39;<\/p>\n<p>INSERT INTO users (name, age) VALUES (%s, %s)<\/p>\n<p>&#39;&#39;&#39;, (&quot;John Doe&quot;, 30))<\/p>\n<h2><strong>\u63d0\u4ea4\u4e8b\u52a1<\/strong><\/h2>\n<p>conn.commit()<\/p>\n<p>conn.close()<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><h5>\u8bfb\u53d6\u6570\u636e<\/h5>\n<\/p>\n<p><pre><code class=\"language-python\">conn = mysql.connector.connect(<\/p>\n<p>    host=&quot;localhost&quot;,<\/p>\n<p>    user=&quot;yourusername&quot;,<\/p>\n<p>    password=&quot;yourpassword&quot;,<\/p>\n<p>    database=&quot;yourdatabase&quot;<\/p>\n<p>)<\/p>\n<p>cursor = conn.cursor()<\/p>\n<h2><strong>\u67e5\u8be2\u6570\u636e<\/strong><\/h2>\n<p>cursor.execute(&#39;&#39;&#39;<\/p>\n<p>SELECT * FROM users<\/p>\n<p>&#39;&#39;&#39;)<\/p>\n<p>for row in cursor.fetchall():<\/p>\n<p>    print(row)<\/p>\n<p>conn.close()<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><h5>\u66f4\u65b0\u6570\u636e<\/h5>\n<\/p>\n<p><pre><code class=\"language-python\">conn = mysql.connector.connect(<\/p>\n<p>    host=&quot;localhost&quot;,<\/p>\n<p>    user=&quot;yourusername&quot;,<\/p>\n<p>    password=&quot;yourpassword&quot;,<\/p>\n<p>    database=&quot;yourdatabase&quot;<\/p>\n<p>)<\/p>\n<p>cursor = conn.cursor()<\/p>\n<h2><strong>\u66f4\u65b0\u6570\u636e<\/strong><\/h2>\n<p>cursor.execute(&#39;&#39;&#39;<\/p>\n<p>UPDATE users SET age = %s WHERE name = %s<\/p>\n<p>&#39;&#39;&#39;, (31, &quot;John Doe&quot;))<\/p>\n<h2><strong>\u63d0\u4ea4\u4e8b\u52a1<\/strong><\/h2>\n<p>conn.commit()<\/p>\n<p>conn.close()<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><h5>\u5220\u9664\u6570\u636e<\/h5>\n<\/p>\n<p><pre><code class=\"language-python\">conn = mysql.connector.connect(<\/p>\n<p>    host=&quot;localhost&quot;,<\/p>\n<p>    user=&quot;yourusername&quot;,<\/p>\n<p>    password=&quot;yourpassword&quot;,<\/p>\n<p>    database=&quot;yourdatabase&quot;<\/p>\n<p>)<\/p>\n<p>cursor = conn.cursor()<\/p>\n<h2><strong>\u5220\u9664\u6570\u636e<\/strong><\/h2>\n<p>cursor.execute(&#39;&#39;&#39;<\/p>\n<p>DELETE FROM users WHERE name = %s<\/p>\n<p>&#39;&#39;&#39;, (&quot;John Doe&quot;,))<\/p>\n<h2><strong>\u63d0\u4ea4\u4e8b\u52a1<\/strong><\/h2>\n<p>conn.commit()<\/p>\n<p>conn.close()<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><h4>5.3 PostgreSQL<\/h4>\n<\/p>\n<p><h5>\u521b\u5efa\u6570\u636e<\/h5>\n<\/p>\n<p><pre><code class=\"language-python\">import psycopg2<\/p>\n<p>conn = psycopg2.connect(<\/p>\n<p>    host=&quot;localhost&quot;,<\/p>\n<p>    database=&quot;yourdatabase&quot;,<\/p>\n<p>    user=&quot;yourusername&quot;,<\/p>\n<p>    password=&quot;yourpassword&quot;<\/p>\n<p>)<\/p>\n<p>cursor = conn.cursor()<\/p>\n<h2><strong>\u63d2\u5165\u6570\u636e<\/strong><\/h2>\n<p>cursor.execute(&#39;&#39;&#39;<\/p>\n<p>INSERT INTO users (name, age) VALUES (%s, %s)<\/p>\n<p>&#39;&#39;&#39;, (&quot;John Doe&quot;, 30))<\/p>\n<h2><strong>\u63d0\u4ea4\u4e8b\u52a1<\/strong><\/h2>\n<p>conn.commit()<\/p>\n<p>conn.close()<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><h5>\u8bfb\u53d6\u6570\u636e<\/h5>\n<\/p>\n<p><pre><code class=\"language-python\">conn = psycopg2.connect(<\/p>\n<p>    host=&quot;localhost&quot;,<\/p>\n<p>    database=&quot;yourdatabase&quot;,<\/p>\n<p>    user=&quot;yourusername&quot;,<\/p>\n<p>    password=&quot;yourpassword&quot;<\/p>\n<p>)<\/p>\n<p>cursor = conn.cursor()<\/p>\n<h2><strong>\u67e5\u8be2\u6570\u636e<\/strong><\/h2>\n<p>cursor.execute(&#39;&#39;&#39;<\/p>\n<p>SELECT * FROM users<\/p>\n<p>&#39;&#39;&#39;)<\/p>\n<p>for row in cursor.fetchall():<\/p>\n<p>    print(row)<\/p>\n<p>conn.close()<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><h5>\u66f4\u65b0\u6570\u636e<\/h5>\n<\/p>\n<p><pre><code class=\"language-python\">conn = psycopg2.connect(<\/p>\n<p>    host=&quot;localhost&quot;,<\/p>\n<p>    database=&quot;yourdatabase&quot;,<\/p>\n<p>    user=&quot;yourusername&quot;,<\/p>\n<p>    password=&quot;yourpassword&quot;<\/p>\n<p>)<\/p>\n<p>cursor = conn.cursor()<\/p>\n<h2><strong>\u66f4\u65b0\u6570\u636e<\/strong><\/h2>\n<p>cursor.execute(&#39;&#39;&#39;<\/p>\n<p>UPDATE users SET age = %s WHERE name = %s<\/p>\n<p>&#39;&#39;&#39;, (31, &quot;John Doe&quot;))<\/p>\n<h2><strong>\u63d0\u4ea4\u4e8b\u52a1<\/strong><\/h2>\n<p>conn.commit()<\/p>\n<p>conn.close()<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><h5>\u5220\u9664\u6570\u636e<\/h5>\n<\/p>\n<p><pre><code class=\"language-python\">conn = psycopg2.connect(<\/p>\n<p>    host=&quot;localhost&quot;,<\/p>\n<p>    database=&quot;yourdatabase&quot;,<\/p>\n<p>    user=&quot;yourusername&quot;,<\/p>\n<p>    password=&quot;yourpassword&quot;<\/p>\n<p>)<\/p>\n<p>cursor = conn.cursor()<\/p>\n<h2><strong>\u5220\u9664\u6570\u636e<\/strong><\/h2>\n<p>cursor.execute(&#39;&#39;&#39;<\/p>\n<p>DELETE FROM users WHERE name = %s<\/p>\n<p>&#39;&#39;&#39;, (&quot;John Doe&quot;,))<\/p>\n<h2><strong>\u63d0\u4ea4\u4e8b\u52a1<\/strong><\/h2>\n<p>conn.commit()<\/p>\n<p>conn.close()<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><h4>5.4 MongoDB<\/h4>\n<\/p>\n<p><h5>\u521b\u5efa\u6570\u636e<\/h5>\n<\/p>\n<p><pre><code class=\"language-python\">from pymongo import MongoClient<\/p>\n<p>client = MongoClient(&#39;localhost&#39;, 27017)<\/p>\n<p>db = client.yourdatabase<\/p>\n<h2><strong>\u63d2\u5165\u6587\u6863<\/strong><\/h2>\n<p>db.users.insert_one({&quot;name&quot;: &quot;John Doe&quot;, &quot;age&quot;: 30})<\/p>\n<h2><strong>\u5173\u95ed\u8fde\u63a5<\/strong><\/h2>\n<p>client.close()<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><h5>\u8bfb\u53d6\u6570\u636e<\/h5>\n<\/p>\n<p><pre><code class=\"language-python\">client = MongoClient(&#39;localhost&#39;, 27017)<\/p>\n<p>db = client.yourdatabase<\/p>\n<h2><strong>\u67e5\u8be2\u6587\u6863<\/strong><\/h2>\n<p>for user in db.users.find():<\/p>\n<p>    print(user)<\/p>\n<h2><strong>\u5173\u95ed\u8fde\u63a5<\/strong><\/h2>\n<p>client.close()<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><h5>\u66f4\u65b0\u6570\u636e<\/h5>\n<\/p>\n<p><pre><code class=\"language-python\">client = MongoClient(&#39;localhost&#39;, 27017)<\/p>\n<p>db = client.yourdatabase<\/p>\n<h2><strong>\u66f4\u65b0\u6587\u6863<\/strong><\/h2>\n<p>db.users.update_one({&quot;name&quot;: &quot;John Doe&quot;}, {&quot;$set&quot;: {&quot;age&quot;: 31}})<\/p>\n<h2><strong>\u5173\u95ed\u8fde\u63a5<\/strong><\/h2>\n<p>client.close()<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><h5>\u5220\u9664\u6570\u636e<\/h5>\n<\/p>\n<p><pre><code class=\"language-python\">client = MongoClient(&#39;localhost&#39;, 27017)<\/p>\n<p>db = client.yourdatabase<\/p>\n<h2><strong>\u5220\u9664\u6587\u6863<\/strong><\/h2>\n<p>db.users.delete_one({&quot;name&quot;: &quot;John Doe&quot;})<\/p>\n<h2><strong>\u5173\u95ed\u8fde\u63a5<\/strong><\/h2>\n<p>client.close()<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><h3>\u516d\u3001\u6700\u4f73\u5b9e\u8df5<\/h3>\n<\/p>\n<p><p>\u5728\u5b9e\u9645\u5e94\u7528\u4e2d\uff0c\u9075\u5faa\u4e00\u4e9b\u6700\u4f73\u5b9e\u8df5\u53ef\u4ee5\u63d0\u9ad8\u6570\u636e\u5e93\u64cd\u4f5c\u7684\u6548\u7387\u548c\u5b89\u5168\u6027\u3002<\/p>\n<\/p>\n<p><h4>6.1 \u4f7f\u7528ORM<\/h4>\n<\/p>\n<p><p>\u5bf9\u8c61\u5173\u7cfb\u6620\u5c04\uff08ORM\uff09\u662f\u5c06\u6570\u636e\u5e93\u8868\u6620\u5c04\u5230\u7c7b\u548c\u5bf9\u8c61\u7684\u4e00\u79cd\u6280\u672f\u3002\u4f7f\u7528ORM\u53ef\u4ee5\u7b80\u5316\u6570\u636e\u5e93\u64cd\u4f5c\uff0c\u51cf\u5c11\u9519\u8bef\u5e76\u63d0\u9ad8\u4ee3\u7801\u7684\u53ef\u7ef4\u62a4\u6027\u3002\u5e38\u89c1\u7684ORM\u5de5\u5177\u5305\u62ecSQLAlchemy\u3001Django ORM\u548cPeewee\u3002<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">from sqlalchemy import create_engine, Column, Integer, String, Sequence<\/p>\n<p>from sqlalchemy.ext.declarative import declarative_base<\/p>\n<p>from sqlalchemy.orm import sessionmaker<\/p>\n<p>Base = declarative_base()<\/p>\n<p>class User(Base):<\/p>\n<p>    __tablename__ = &#39;users&#39;<\/p>\n<p>    id = Column(Integer, Sequence(&#39;user_id_seq&#39;), primary_key=True)<\/p>\n<p>    name = Column(String(50))<\/p>\n<p>    age = Column(Integer)<\/p>\n<p>engine = create_engine(&#39;sqlite:\/\/\/example.db&#39;)<\/p>\n<p>Base.metadata.create_all(engine)<\/p>\n<p>Session = sessionmaker(bind=engine)<\/p>\n<p>session = Session()<\/p>\n<h2><strong>\u63d2\u5165\u6570\u636e<\/strong><\/h2>\n<p>new_user = User(name=&#39;John Doe&#39;, age=30)<\/p>\n<p>session.add(new_user)<\/p>\n<p>session.commit()<\/p>\n<h2><strong>\u67e5\u8be2\u6570\u636e<\/strong><\/h2>\n<p>for user in session.query(User).all():<\/p>\n<p>    print(user.name, user.age)<\/p>\n<p>session.close()<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><h4>6.2 \u4f7f\u7528\u4e8b\u52a1<\/h4>\n<\/p>\n<p><p>\u4e8b\u52a1\u662f\u4e00\u7ec4\u64cd\u4f5c\u7684\u96c6\u5408\uff0c\u8981\u4e48\u5168\u90e8\u6267\u884c\u6210\u529f\uff0c\u8981\u4e48\u5168\u90e8\u56de\u6eda\u3002\u4f7f\u7528\u4e8b\u52a1\u53ef\u4ee5\u786e\u4fdd\u6570\u636e\u7684\u4e00\u81f4\u6027\u548c\u5b8c\u6574\u6027\u3002<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">conn = sqlite3.connect(&#39;example.db&#39;)<\/p>\n<p>try:<\/p>\n<p>    cursor = conn.cursor()<\/p>\n<p>    cursor.execute(&quot;BEGIN TRANSACTION&quot;)<\/p>\n<p>    # \u63d2\u5165\u6570\u636e<\/p>\n<p>    cursor.execute(&#39;&#39;&#39;<\/p>\n<p>    INSERT INTO users (name, age) VALUES (?, ?)<\/p>\n<p>    &#39;&#39;&#39;, (&quot;John Doe&quot;, 30))<\/p>\n<p>    # \u66f4\u65b0\u6570\u636e<\/p>\n<p>    cursor.execute(&#39;&#39;&#39;<\/p>\n<p>    UPDATE users SET age = ? WHERE name = ?<\/p>\n<p>    &#39;&#39;&#39;, (31, &quot;John Doe&quot;))<\/p>\n<p>    # \u63d0\u4ea4\u4e8b\u52a1<\/p>\n<p>    conn.commit()<\/p>\n<p>except sqlite3.Error as e:<\/p>\n<p>    # \u56de\u6eda\u4e8b\u52a1<\/p>\n<p>    conn.rollback()<\/p>\n<p>    print(&quot;Transaction f<a href=\"https:\/\/docs.pingcode.com\/blog\/59162.html\" target=\"_blank\">AI<\/a>led:&quot;, e)<\/p>\n<p>finally:<\/p>\n<p>    conn.close()<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><h4>6.3 \u53c2\u6570\u5316\u67e5\u8be2<\/h4>\n<\/p>\n<p><p>\u53c2\u6570\u5316\u67e5\u8be2\u53ef\u4ee5\u9632\u6b62SQL\u6ce8\u5165\u653b\u51fb\uff0c\u63d0\u9ad8\u6570\u636e\u5e93\u64cd\u4f5c\u7684\u5b89\u5168\u6027\u3002<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">name = &quot;John Doe&quot;<\/p>\n<p>age = 30<\/p>\n<p>conn = sqlite3.connect(&#39;example.db&#39;)<\/p>\n<p>cursor = conn.cursor()<\/p>\n<h2><strong>\u4f7f\u7528\u53c2\u6570\u5316\u67e5\u8be2<\/strong><\/h2>\n<p>cursor.execute(&#39;&#39;&#39;<\/p>\n<p>INSERT INTO users (name, age) VALUES (?, ?)<\/p>\n<p>&#39;&#39;&#39;, (name, age))<\/p>\n<p>conn.commit()<\/p>\n<p>conn.close()<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><h3>\u603b\u7ed3<\/h3>\n<\/p>\n<p><p>\u672c\u6587\u8be6\u7ec6\u4ecb\u7ecd\u4e86\u5982\u4f55\u4f7f\u7528Python\u521b\u5efa\u548c\u64cd\u4f5c\u4e0d\u540c\u7c7b\u578b\u7684\u6570\u636e\u5e93\uff0c\u4ece\u9009\u62e9\u6570\u636e\u5e93\u7ba1\u7406\u7cfb\u7edf\u3001\u5b89\u88c5\u5fc5\u8981\u7684\u8f6f\u4ef6\u548c\u5e93\u3001\u8fde\u63a5\u6570\u636e\u5e93\u3001\u521b\u5efa\u6570\u636e\u5e93\u548c\u8868\u5230\u6267\u884cCRUD\u64cd\u4f5c\u3002\u540c\u65f6\uff0c\u6211\u4eec\u8fd8\u8ba8\u8bba\u4e86\u4f7f\u7528ORM\u3001\u4e8b\u52a1\u548c\u53c2\u6570\u5316\u67e5\u8be2\u7b49\u6700\u4f73\u5b9e\u8df5\u3002\u901a\u8fc7\u9075\u5faa\u8fd9\u4e9b\u6b65\u9aa4\u548c\u5efa\u8bae\uff0c\u60a8\u53ef\u4ee5\u8f7b\u677e\u5730\u4f7f\u7528Python\u521b\u5efa\u548c\u7ba1\u7406\u6570\u636e\u5e93\uff0c\u5e76\u786e\u4fdd\u6570\u636e\u7684\u5b89\u5168\u6027\u548c\u4e00\u81f4\u6027\u3002<\/p>\n<\/p>\n<h2><strong>\u76f8\u5173\u95ee\u7b54FAQs\uff1a<\/strong><\/h2>\n<p> <strong>\u5982\u4f55\u9009\u62e9\u9002\u5408\u7684\u6570\u636e\u5e93\u6765\u4e0ePython\u914d\u5408\u4f7f\u7528\uff1f<\/strong><br \/>\u5728\u9009\u62e9\u6570\u636e\u5e93\u65f6\uff0c\u60a8\u9700\u8981\u8003\u8651\u9879\u76ee\u7684\u9700\u6c42\u3002\u5173\u7cfb\u578b\u6570\u636e\u5e93\u5982MySQL\u548cPostgreSQL\u9002\u5408\u9700\u8981\u590d\u6742\u67e5\u8be2\u7684\u5e94\u7528\uff0c\u800c\u975e\u5173\u7cfb\u578b\u6570\u636e\u5e93\u5982MongoDB\u5219\u66f4\u9002\u5408\u5904\u7406\u5927\u91cf\u975e\u7ed3\u6784\u5316\u6570\u636e\u3002Python\u652f\u6301\u591a\u79cd\u6570\u636e\u5e93\uff0c\u60a8\u53ef\u4ee5\u4f7f\u7528ORM\u6846\u67b6\u5982SQLAlchemy\u6765\u7b80\u5316\u64cd\u4f5c\u3002<\/p>\n<p><strong>\u4f7f\u7528Python\u8fde\u63a5\u6570\u636e\u5e93\u7684\u57fa\u672c\u6b65\u9aa4\u6709\u54ea\u4e9b\uff1f<\/strong><br \/>\u8fde\u63a5\u6570\u636e\u5e93\u901a\u5e38\u5305\u62ec\u5b89\u88c5\u76f8\u5e94\u7684\u6570\u636e\u5e93\u9a71\u52a8\u5305\u3001\u521b\u5efa\u6570\u636e\u5e93\u8fde\u63a5\u3001\u6267\u884cSQL\u8bed\u53e5\u4ee5\u53ca\u5904\u7406\u7ed3\u679c\u3002\u5e38\u7528\u7684\u5e93\u6709<code>sqlite3<\/code>\uff08\u9002\u5408\u8f7b\u91cf\u7ea7\u5e94\u7528\uff09\u3001<code>psycopg2<\/code>\uff08\u7528\u4e8ePostgreSQL\uff09\u548c<code>PyMySQL<\/code>\uff08\u7528\u4e8eMySQL\uff09\u3002\u901a\u8fc7\u8fd9\u4e9b\u5e93\uff0c\u60a8\u53ef\u4ee5\u8f7b\u677e\u5b9e\u73b0CRUD\u64cd\u4f5c\u3002<\/p>\n<p><strong>\u5728Python\u4e2d\u5982\u4f55\u8fdb\u884c\u6570\u636e\u5e93\u7684\u5b89\u5168\u6027\u5904\u7406\uff1f<\/strong><br \/>\u5b89\u5168\u6027\u662f\u6570\u636e\u5e93\u64cd\u4f5c\u4e2d\u975e\u5e38\u91cd\u8981\u7684\u4e00\u73af\u3002\u4f7f\u7528\u53c2\u6570\u5316\u67e5\u8be2\u53ef\u4ee5\u6709\u6548\u9632\u6b62SQL\u6ce8\u5165\u653b\u51fb\u3002\u6b64\u5916\uff0c\u786e\u4fdd\u6570\u636e\u5e93\u7684\u7528\u6237\u6743\u9650\u8bbe\u7f6e\u5408\u7406\uff0c\u5b9a\u671f\u66f4\u65b0\u6570\u636e\u5e93\u53ca\u5176\u9a71\u52a8\u7a0b\u5e8f\uff0c\u80fd\u591f\u8fdb\u4e00\u6b65\u63d0\u9ad8\u5b89\u5168\u6027\u3002\u4f7f\u7528\u73af\u5883\u53d8\u91cf\u5b58\u50a8\u654f\u611f\u4fe1\u606f\uff0c\u800c\u4e0d\u662f\u5728\u4ee3\u7801\u4e2d\u786c\u7f16\u7801\uff0c\u4e5f\u662f\u4e00\u4e2a\u826f\u597d\u7684\u5b9e\u8df5\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"\u7528Python\u521b\u5efa\u6570\u636e\u5e93\u7684\u65b9\u6cd5\u5305\u62ec\uff1a\u9009\u62e9\u6570\u636e\u5e93\u7ba1\u7406\u7cfb\u7edf\u3001\u5b89\u88c5\u5fc5\u8981\u7684\u8f6f\u4ef6\u548c\u5e93\u3001\u8fde\u63a5\u6570\u636e\u5e93\u3001\u521b\u5efa\u6570\u636e\u5e93\u548c\u8868\u3001\u6267\u884cC [&hellip;]","protected":false},"author":3,"featured_media":1136920,"comment_status":"closed","ping_status":"","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[37],"tags":[],"acf":[],"_links":{"self":[{"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/posts\/1136909"}],"collection":[{"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/users\/3"}],"replies":[{"embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/comments?post=1136909"}],"version-history":[{"count":"1","href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/posts\/1136909\/revisions"}],"predecessor-version":[{"id":1136922,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/posts\/1136909\/revisions\/1136922"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/media\/1136920"}],"wp:attachment":[{"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/media?parent=1136909"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/categories?post=1136909"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/tags?post=1136909"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}