{"id":985282,"date":"2024-12-27T07:35:22","date_gmt":"2024-12-26T23:35:22","guid":{"rendered":"https:\/\/docs.pingcode.com\/ask\/ask-ask\/985282.html"},"modified":"2024-12-27T07:35:24","modified_gmt":"2024-12-26T23:35:24","slug":"%e5%a6%82%e4%bd%95%e7%94%a8python%e6%95%b0%e6%8d%ae%e5%85%a5%e5%ba%93","status":"publish","type":"post","link":"https:\/\/docs.pingcode.com\/ask\/985282.html","title":{"rendered":"\u5982\u4f55\u7528python\u6570\u636e\u5165\u5e93"},"content":{"rendered":"<p style=\"text-align:center;\" ><img decoding=\"async\" src=\"https:\/\/cdn-kb.worktile.com\/kb\/wp-content\/uploads\/2024\/04\/24212521\/d6e9b30b-08f8-4551-ad82-063f96d236ea.webp\" alt=\"\u5982\u4f55\u7528python\u6570\u636e\u5165\u5e93\" \/><\/p>\n<p><p> <strong>\u4f7f\u7528Python\u8fdb\u884c\u6570\u636e\u5165\u5e93\u7684\u65b9\u6cd5\u4e3b\u8981\u5305\u62ec\u4f7f\u7528SQLAlchemy\u3001Pandas\u5e93\u7684to_sql\u65b9\u6cd5\u3001\u76f4\u63a5\u4f7f\u7528\u6570\u636e\u5e93\u9a71\u52a8\u5e93\uff08\u5982PyMySQL\u3001psycopg2\uff09\u7b49\u3002<\/strong>\u5176\u4e2d\uff0c<strong>SQLAlchemy<\/strong>\u662f\u4e00\u4e2a\u529f\u80fd\u5f3a\u5927\u7684ORM\u5e93\uff0c\u5b83\u63d0\u4f9b\u4e86\u4e00\u4e2a\u7b80\u5355\u800c\u7075\u6d3b\u7684\u63a5\u53e3\uff0c\u53ef\u4ee5\u8f7b\u677e\u5730\u5c06Python\u5bf9\u8c61\u6620\u5c04\u5230\u6570\u636e\u5e93\u8868\uff1b<strong>Pandas\u7684to_sql\u65b9\u6cd5<\/strong>\u5141\u8bb8\u76f4\u63a5\u5c06\u6570\u636e\u6846\u5199\u5165\u6570\u636e\u5e93\uff0c\u975e\u5e38\u9002\u5408\u5904\u7406\u6279\u91cf\u6570\u636e\uff1b\u800c<strong>\u6570\u636e\u5e93\u9a71\u52a8\u5e93<\/strong>\u5219\u63d0\u4f9b\u4e86\u4e0e\u7279\u5b9a\u6570\u636e\u5e93\u7684\u76f4\u63a5\u63a5\u53e3\uff0c\u9002\u5408\u9700\u8981\u9ad8\u5ea6\u81ea\u5b9a\u4e49\u7684\u573a\u666f\u3002\u63a5\u4e0b\u6765\uff0c\u6211\u5c06\u8be6\u7ec6\u4ecb\u7ecd\u5982\u4f55\u4f7f\u7528SQLAlchemy\u8fdb\u884c\u6570\u636e\u5165\u5e93\u3002<\/p>\n<\/p>\n<p><h3>\u4e00\u3001SQLALCHEMY\u4f7f\u7528<\/h3>\n<\/p>\n<p><p>SQLAlchemy\u662f\u4e00\u4e2a\u975e\u5e38\u6d41\u884c\u7684Python\u5e93\uff0c\u7528\u4e8e\u4e0e\u5173\u7cfb\u6570\u636e\u5e93\u4ea4\u4e92\u3002\u5b83\u63d0\u4f9b\u4e86\u4e00\u4e2a\u9ad8\u7ea7\u62bd\u8c61\u5c42\uff0c\u8ba9\u5f00\u53d1\u8005\u53ef\u4ee5\u4ee5\u9762\u5411\u5bf9\u8c61\u7684\u65b9\u5f0f\u4e0e\u6570\u636e\u5e93\u4ea4\u4e92\uff0c\u800c\u4e0d\u662f\u76f4\u63a5\u4f7f\u7528SQL\u67e5\u8be2\u3002<\/p>\n<\/p>\n<p><h4>1. \u5b89\u88c5SQLAlchemy<\/h4>\n<\/p>\n<p><p>\u9996\u5148\uff0c\u4f60\u9700\u8981\u5b89\u88c5SQLAlchemy\u3002\u53ef\u4ee5\u901a\u8fc7pip\u547d\u4ee4\u5b89\u88c5\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-bash\">pip install sqlalchemy<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><h4>2. \u5efa\u7acb\u6570\u636e\u5e93\u8fde\u63a5<\/h4>\n<\/p>\n<p><p>\u4f7f\u7528SQLAlchemy\u8fde\u63a5\u6570\u636e\u5e93\u7684\u7b2c\u4e00\u6b65\u662f\u521b\u5efa\u4e00\u4e2a<code>Engine<\/code>\u3002<code>Engine<\/code>\u5bf9\u8c61\u662fSQLAlchemy\u4e0e\u6570\u636e\u5e93\u4ea4\u4e92\u7684\u6838\u5fc3\uff0c\u5b83\u8d1f\u8d23SQL\u8bed\u53e5\u7684\u6267\u884c\u548c\u6570\u636e\u5e93\u8fde\u63a5\u7684\u7ba1\u7406\u3002<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">from sqlalchemy import create_engine<\/p>\n<h2><strong>\u793a\u4f8b\uff1a\u8fde\u63a5\u5230MySQL\u6570\u636e\u5e93<\/strong><\/h2>\n<p>engine = create_engine(&#39;mysql+pymysql:\/\/username:password@localhost:3306\/database_name&#39;)<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u5728\u4e0a\u9762\u7684\u4ee3\u7801\u4e2d\uff0c\u4f60\u9700\u8981\u5c06<code>username<\/code>\u3001<code>password<\/code>\u548c<code>database_name<\/code>\u66ff\u6362\u4e3a\u4f60\u7684\u6570\u636e\u5e93\u7528\u6237\u540d\u3001\u5bc6\u7801\u548c\u6570\u636e\u5e93\u540d\u3002<\/p>\n<\/p>\n<p><h4>3. \u5b9a\u4e49\u6a21\u578b<\/h4>\n<\/p>\n<p><p>\u5728SQLAlchemy\u4e2d\uff0c\u4f60\u53ef\u4ee5\u4f7f\u7528Python\u7c7b\u5b9a\u4e49\u6570\u636e\u5e93\u8868\u7684\u7ed3\u6784\u3002\u8fd9\u4e9b\u7c7b\u79f0\u4e3a\u6a21\u578b\u3002<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">from sqlalchemy.ext.declarative import declarative_base<\/p>\n<p>from sqlalchemy import Column, Integer, String<\/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, primary_key=True)<\/p>\n<p>    name = Column(String(50))<\/p>\n<p>    age = Column(Integer)<\/p>\n<p>    def __repr__(self):<\/p>\n<p>        return f&quot;&lt;User(name=&#39;{self.name}&#39;, age=&#39;{self.age}&#39;)&gt;&quot;<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u5728\u8fd9\u4e2a\u4f8b\u5b50\u4e2d\uff0c\u6211\u4eec\u5b9a\u4e49\u4e86\u4e00\u4e2a\u540d\u4e3a<code>User<\/code>\u7684\u6a21\u578b\uff0c\u5b83\u6620\u5c04\u5230\u6570\u636e\u5e93\u4e2d\u7684<code>users<\/code>\u8868\u3002<code>id<\/code>\u3001<code>name<\/code>\u548c<code>age<\/code>\u662f\u8868\u4e2d\u7684\u5217\u3002<\/p>\n<\/p>\n<p><h4>4. \u521b\u5efa\u8868<\/h4>\n<\/p>\n<p><p>\u4e00\u65e6\u5b9a\u4e49\u4e86\u6a21\u578b\uff0c\u4f60\u53ef\u4ee5\u4f7f\u7528<code>Base.metadata.create_all(engine)<\/code>\u65b9\u6cd5\u5728\u6570\u636e\u5e93\u4e2d\u521b\u5efa\u76f8\u5e94\u7684\u8868\u3002<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">Base.metadata.create_all(engine)<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><h4>5. \u63d2\u5165\u6570\u636e<\/h4>\n<\/p>\n<p><p>\u4f7f\u7528SQLAlchemy\u63d2\u5165\u6570\u636e\u975e\u5e38\u7b80\u5355\u3002\u9996\u5148\uff0c\u4f60\u9700\u8981\u521b\u5efa\u4e00\u4e2a<code>Session<\/code>\u5bf9\u8c61\uff0c\u5b83\u4ee3\u8868\u4e86\u4e0e\u6570\u636e\u5e93\u7684\u4e00\u6b21\u4f1a\u8bdd\u3002<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">from sqlalchemy.orm import sessionmaker<\/p>\n<p>Session = sessionmaker(bind=engine)<\/p>\n<p>session = Session()<\/p>\n<h2><strong>\u521b\u5efa\u4e00\u4e2a\u65b0\u7684User\u5bf9\u8c61<\/strong><\/h2>\n<p>new_user = User(name=&#39;John Doe&#39;, age=30)<\/p>\n<h2><strong>\u6dfb\u52a0\u5230\u4f1a\u8bdd<\/strong><\/h2>\n<p>session.add(new_user)<\/p>\n<h2><strong>\u63d0\u4ea4\u4e8b\u52a1<\/strong><\/h2>\n<p>session.commit()<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u5728\u8fd9\u4e2a\u4f8b\u5b50\u4e2d\uff0c\u6211\u4eec\u521b\u5efa\u4e86\u4e00\u4e2a\u65b0\u7684<code>User<\/code>\u5bf9\u8c61\u5e76\u5c06\u5176\u6dfb\u52a0\u5230\u4f1a\u8bdd\uff0c\u7136\u540e\u63d0\u4ea4\u4e8b\u52a1\u4ee5\u5c06\u66f4\u6539\u4fdd\u5b58\u5230\u6570\u636e\u5e93\u3002<\/p>\n<\/p>\n<p><h4>6. \u67e5\u8be2\u6570\u636e<\/h4>\n<\/p>\n<p><p>SQLAlchemy\u63d0\u4f9b\u4e86\u4e00\u4e2a\u529f\u80fd\u5f3a\u5927\u7684\u67e5\u8be2\u63a5\u53e3\uff0c\u53ef\u4ee5\u7528\u6765\u4ece\u6570\u636e\u5e93\u4e2d\u68c0\u7d22\u6570\u636e\u3002<\/p>\n<\/p>\n<p><pre><code class=\"language-python\"># \u67e5\u8be2\u6240\u6709\u7528\u6237<\/p>\n<p>users = session.query(User).all()<\/p>\n<p>for user in users:<\/p>\n<p>    print(user)<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u8fd9\u4e2a\u67e5\u8be2\u5c06\u68c0\u7d22<code>users<\/code>\u8868\u4e2d\u7684\u6240\u6709\u884c\uff0c\u5e76\u8fd4\u56de\u4e00\u4e2a<code>User<\/code>\u5bf9\u8c61\u5217\u8868\u3002<\/p>\n<\/p>\n<p><h3>\u4e8c\u3001PANDAS\u7684TO_SQL\u65b9\u6cd5<\/h3>\n<\/p>\n<p><p>Pandas\u662f\u4e00\u4e2a\u5f3a\u5927\u7684\u6570\u636e\u5206\u6790\u5e93\uff0c\u63d0\u4f9b\u4e86\u8bb8\u591a\u65b9\u4fbf\u7684\u6570\u636e\u5904\u7406\u65b9\u6cd5\u3002\u5b83\u7684<code>to_sql<\/code>\u65b9\u6cd5\u5141\u8bb8\u4f60\u5c06DataFrame\u76f4\u63a5\u5199\u5165\u6570\u636e\u5e93\u3002<\/p>\n<\/p>\n<p><h4>1. \u5b89\u88c5Pandas<\/h4>\n<\/p>\n<p><p>\u9996\u5148\uff0c\u786e\u4fdd\u4f60\u5df2\u7ecf\u5b89\u88c5\u4e86Pandas\u5e93\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-bash\">pip install pandas<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><h4>2. \u4f7f\u7528to_sql\u65b9\u6cd5<\/h4>\n<\/p>\n<p><p>\u4f7f\u7528<code>to_sql<\/code>\u65b9\u6cd5\u53ef\u4ee5\u5c06DataFrame\u5199\u5165\u6570\u636e\u5e93\u8868\u4e2d\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">import pandas as pd<\/p>\n<h2><strong>\u793a\u4f8b\u6570\u636e<\/strong><\/h2>\n<p>data = {<\/p>\n<p>    &#39;name&#39;: [&#39;Alice&#39;, &#39;Bob&#39;, &#39;Charlie&#39;],<\/p>\n<p>    &#39;age&#39;: [25, 30, 35]<\/p>\n<p>}<\/p>\n<p>df = pd.DataFrame(data)<\/p>\n<h2><strong>\u5c06DataFrame\u5199\u5165\u6570\u636e\u5e93<\/strong><\/h2>\n<p>df.to_sql(&#39;users&#39;, con=engine, if_exists=&#39;replace&#39;, index=False)<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u5728\u8fd9\u4e2a\u4f8b\u5b50\u4e2d\uff0c\u6211\u4eec\u521b\u5efa\u4e86\u4e00\u4e2a\u5305\u542b\u540d\u5b57\u548c\u5e74\u9f84\u7684DataFrame\uff0c\u5e76\u5c06\u5176\u5199\u5165\u6570\u636e\u5e93\u7684<code>users<\/code>\u8868\u4e2d\u3002<\/p>\n<\/p>\n<p><h3>\u4e09\u3001\u4f7f\u7528\u6570\u636e\u5e93\u9a71\u52a8\u5e93<\/h3>\n<\/p>\n<p><p>\u5bf9\u4e8e\u9700\u8981\u76f4\u63a5\u4e0e\u6570\u636e\u5e93\u4ea4\u4e92\u7684\u573a\u666f\uff0c\u53ef\u4ee5\u4f7f\u7528\u6570\u636e\u5e93\u9a71\u52a8\u5e93\u3002\u8fd9\u91cc\u4ee5PyMySQL\u548cpsycopg2\u4e3a\u4f8b\uff0c\u5206\u522b\u4ecb\u7ecd\u5982\u4f55\u4e0eMySQL\u548cPostgreSQL\u6570\u636e\u5e93\u4ea4\u4e92\u3002<\/p>\n<\/p>\n<p><h4>1. \u4f7f\u7528PyMySQL\u8fde\u63a5MySQL\u6570\u636e\u5e93<\/h4>\n<\/p>\n<p><p>\u9996\u5148\uff0c\u5b89\u88c5PyMySQL\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-bash\">pip install pymysql<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u7136\u540e\uff0c\u4f7f\u7528PyMySQL\u8fde\u63a5MySQL\u6570\u636e\u5e93\u5e76\u6267\u884c\u67e5\u8be2\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">import pymysql<\/p>\n<h2><strong>\u8fde\u63a5\u5230MySQL\u6570\u636e\u5e93<\/strong><\/h2>\n<p>connection = pymysql.connect(<\/p>\n<p>    host=&#39;localhost&#39;,<\/p>\n<p>    user=&#39;username&#39;,<\/p>\n<p>    password=&#39;password&#39;,<\/p>\n<p>    database=&#39;database_name&#39;<\/p>\n<p>)<\/p>\n<p>try:<\/p>\n<p>    with connection.cursor() as cursor:<\/p>\n<p>        # \u6267\u884cSQL\u67e5\u8be2<\/p>\n<p>        sql = &quot;INSERT INTO users (name, age) VALUES (%s, %s)&quot;<\/p>\n<p>        cursor.execute(sql, (&#39;John Doe&#39;, 28))<\/p>\n<p>    # \u63d0\u4ea4\u4e8b\u52a1<\/p>\n<p>    connection.commit()<\/p>\n<p>finally:<\/p>\n<p>    connection.close()<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><h4>2. \u4f7f\u7528psycopg2\u8fde\u63a5PostgreSQL\u6570\u636e\u5e93<\/h4>\n<\/p>\n<p><p>\u9996\u5148\uff0c\u5b89\u88c5psycopg2\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-bash\">pip install psycopg2<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u7136\u540e\uff0c\u4f7f\u7528psycopg2\u8fde\u63a5PostgreSQL\u6570\u636e\u5e93\u5e76\u6267\u884c\u67e5\u8be2\uff1a<\/p>\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>connection = psycopg2.connect(<\/p>\n<p>    host=&#39;localhost&#39;,<\/p>\n<p>    user=&#39;username&#39;,<\/p>\n<p>    password=&#39;password&#39;,<\/p>\n<p>    database=&#39;database_name&#39;<\/p>\n<p>)<\/p>\n<p>try:<\/p>\n<p>    with connection.cursor() as cursor:<\/p>\n<p>        # \u6267\u884cSQL\u67e5\u8be2<\/p>\n<p>        sql = &quot;INSERT INTO users (name, age) VALUES (%s, %s)&quot;<\/p>\n<p>        cursor.execute(sql, (&#39;Jane Doe&#39;, 32))<\/p>\n<p>    # \u63d0\u4ea4\u4e8b\u52a1<\/p>\n<p>    connection.commit()<\/p>\n<p>finally:<\/p>\n<p>    connection.close()<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><h3>\u56db\u3001\u603b\u7ed3<\/h3>\n<\/p>\n<p><p>\u5728\u8fd9\u7bc7\u6587\u7ae0\u4e2d\uff0c\u6211\u4eec\u8be6\u7ec6\u4ecb\u7ecd\u4e86\u5982\u4f55\u4f7f\u7528Python\u5c06\u6570\u636e\u5165\u5e93\u3002\u6211\u4eec\u63a2\u8ba8\u4e86\u4f7f\u7528SQLAlchemy\u3001Pandas\u7684<code>to_sql<\/code>\u65b9\u6cd5\u4ee5\u53ca\u6570\u636e\u5e93\u9a71\u52a8\u5e93\uff08\u5982PyMySQL\u548cpsycopg2\uff09\u7684\u4e0d\u540c\u65b9\u6cd5\u3002\u9009\u62e9\u54ea\u79cd\u65b9\u6cd5\u53d6\u51b3\u4e8e\u5177\u4f53\u7684\u5e94\u7528\u573a\u666f\u548c\u9700\u6c42\uff1a<strong>SQLAlchemy\u9002\u5408\u9700\u8981\u9762\u5411\u5bf9\u8c61\u6570\u636e\u5e93\u8bbf\u95ee\u7684\u5e94\u7528<\/strong>\uff0c<strong>Pandas\u7684to_sql\u9002\u5408\u6279\u91cf\u6570\u636e\u5904\u7406<\/strong>\uff0c<strong>\u800c\u6570\u636e\u5e93\u9a71\u52a8\u5e93\u63d0\u4f9b\u4e86\u5bf9\u6570\u636e\u5e93\u64cd\u4f5c\u7684\u7ec6\u7c92\u5ea6\u63a7\u5236<\/strong>\u3002\u65e0\u8bba\u9009\u62e9\u54ea\u79cd\u65b9\u6cd5\uff0c\u90fd\u80fd\u901a\u8fc7Python\u9ad8\u6548\u5730\u8fdb\u884c\u6570\u636e\u5165\u5e93\u64cd\u4f5c\u3002<\/p>\n<\/p>\n<h2><strong>\u76f8\u5173\u95ee\u7b54FAQs\uff1a<\/strong><\/h2>\n<p> <strong>\u5982\u4f55\u9009\u62e9\u5408\u9002\u7684\u6570\u636e\u5e93\u6765\u5b58\u50a8Python\u4e2d\u7684\u6570\u636e\uff1f<\/strong><br \/>\u5728\u9009\u62e9\u6570\u636e\u5e93\u65f6\uff0c\u9700\u8981\u8003\u8651\u6570\u636e\u7684\u7c7b\u578b\u548c\u5e94\u7528\u573a\u666f\u3002\u5bf9\u4e8e\u5173\u7cfb\u578b\u6570\u636e\uff0cMySQL\u6216PostgreSQL\u662f\u4e0d\u9519\u7684\u9009\u62e9\uff0c\u5b83\u4eec\u63d0\u4f9b\u5f3a\u5927\u7684\u67e5\u8be2\u529f\u80fd\u548c\u4e8b\u52a1\u652f\u6301\u3002\u5982\u679c\u6570\u636e\u662f\u975e\u7ed3\u6784\u5316\u7684\uff0cMongoDB\u7b49NoSQL\u6570\u636e\u5e93\u53ef\u80fd\u66f4\u4e3a\u9002\u5408\u3002\u786e\u4fdd\u6570\u636e\u5e93\u80fd\u591f\u652f\u6301\u4f60\u6240\u9700\u7684\u6269\u5c55\u6027\u548c\u6027\u80fd\u8981\u6c42\u3002<\/p>\n<p><strong>\u5728Python\u4e2d\u5982\u4f55\u8fde\u63a5\u5230\u6570\u636e\u5e93\uff1f<\/strong><br \/>\u4f7f\u7528Python\u8fde\u63a5\u6570\u636e\u5e93\u901a\u5e38\u4f9d\u8d56\u4e8e\u7279\u5b9a\u7684\u5e93\u3002\u4f8b\u5982\uff0c\u4f7f\u7528MySQL\u6570\u636e\u5e93\u65f6\uff0c\u53ef\u4ee5\u4f7f\u7528<code>mysql-connector-python<\/code>\u6216<code>PyMySQL<\/code>\u5e93\uff0c\u800cPostgreSQL\u53ef\u4ee5\u901a\u8fc7<code>psycopg2<\/code>\u8fdb\u884c\u8fde\u63a5\u3002\u5b89\u88c5\u76f8\u5e94\u7684\u5e93\u540e\uff0c\u4f60\u9700\u8981\u63d0\u4f9b\u6570\u636e\u5e93\u7684\u4e3b\u673a\u5730\u5740\u3001\u7528\u6237\u540d\u3001\u5bc6\u7801\u548c\u6570\u636e\u5e93\u540d\u79f0\uff0c\u7136\u540e\u4f7f\u7528\u8fd9\u4e9b\u4fe1\u606f\u5efa\u7acb\u8fde\u63a5\u3002<\/p>\n<p><strong>\u5982\u4f55\u5c06\u6570\u636e\u4ecePython\u5bfc\u5165\u5230\u6570\u636e\u5e93\u4e2d\uff1f<\/strong><br \/>\u5c06\u6570\u636e\u5bfc\u5165\u6570\u636e\u5e93\u7684\u8fc7\u7a0b\u901a\u5e38\u6d89\u53ca\u521b\u5efa\u6570\u636e\u5e93\u8fde\u63a5\u3001\u51c6\u5907\u6570\u636e\u548c\u6267\u884c\u63d2\u5165\u64cd\u4f5c\u3002\u53ef\u4ee5\u4f7f\u7528SQL\u8bed\u53e5\u8fdb\u884c\u63d2\u5165\uff0c\u4e5f\u53ef\u4ee5\u5229\u7528ORM\uff08\u5bf9\u8c61\u5173\u7cfb\u6620\u5c04\uff09\u5e93\u5982SQLAlchemy\u6216Django ORM\uff0c\u7b80\u5316\u64cd\u4f5c\u3002\u786e\u4fdd\u5728\u63d2\u5165\u6570\u636e\u524d\u5bf9\u6570\u636e\u8fdb\u884c\u6e05\u6d17\u548c\u683c\u5f0f\u5316\uff0c\u4ee5\u907f\u514d\u56e0\u683c\u5f0f\u4e0d\u6b63\u786e\u5bfc\u81f4\u7684\u9519\u8bef\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"\u4f7f\u7528Python\u8fdb\u884c\u6570\u636e\u5165\u5e93\u7684\u65b9\u6cd5\u4e3b\u8981\u5305\u62ec\u4f7f\u7528SQLAlchemy\u3001Pandas\u5e93\u7684to_sql\u65b9\u6cd5\u3001\u76f4\u63a5\u4f7f\u7528 [&hellip;]","protected":false},"author":3,"featured_media":985291,"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\/985282"}],"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=985282"}],"version-history":[{"count":"1","href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/posts\/985282\/revisions"}],"predecessor-version":[{"id":985293,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/posts\/985282\/revisions\/985293"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/media\/985291"}],"wp:attachment":[{"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/media?parent=985282"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/categories?post=985282"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/tags?post=985282"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}