From 1ec37e7cdbd7df396677582923c1314750f1c303 Mon Sep 17 00:00:00 2001 From: erichxchen Date: Sat, 13 Jan 2024 23:00:57 -0500 Subject: [PATCH] Fix EX03 Errors for pandas.DataFrame.to_sql --- ci/code_checks.sh | 1 - pandas/core/generic.py | 10 +++++----- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/ci/code_checks.sh b/ci/code_checks.sh index a08a0cbd87383..1a79ff0e0fd7a 100755 --- a/ci/code_checks.sh +++ b/ci/code_checks.sh @@ -94,7 +94,6 @@ if [[ -z "$CHECK" || "$CHECK" == "docstrings" ]]; then pandas.DataFrame.to_latex \ pandas.io.formats.style.Styler.to_latex \ pandas.read_parquet \ - pandas.DataFrame.to_sql \ pandas.read_stata \ pandas.core.resample.Resampler.pipe \ pandas.core.resample.Resampler.interpolate \ diff --git a/pandas/core/generic.py b/pandas/core/generic.py index b37f22339fcfd..fffd1ceb00fe2 100644 --- a/pandas/core/generic.py +++ b/pandas/core/generic.py @@ -2995,7 +2995,7 @@ def to_sql( 3 >>> from sqlalchemy import text >>> with engine.connect() as conn: - ... conn.execute(text("SELECT * FROM users")).fetchall() + ... conn.execute(text("SELECT * FROM users")).fetchall() [(0, 'User 1'), (1, 'User 2'), (2, 'User 3')] An `sqlalchemy.engine.Connection` can also be passed to `con`: @@ -3012,7 +3012,7 @@ def to_sql( >>> df2.to_sql(name='users', con=engine, if_exists='append') 2 >>> with engine.connect() as conn: - ... conn.execute(text("SELECT * FROM users")).fetchall() + ... conn.execute(text("SELECT * FROM users")).fetchall() [(0, 'User 1'), (1, 'User 2'), (2, 'User 3'), (0, 'User 4'), (1, 'User 5'), (0, 'User 6'), (1, 'User 7')] @@ -3023,7 +3023,7 @@ def to_sql( ... index_label='id') 2 >>> with engine.connect() as conn: - ... conn.execute(text("SELECT * FROM users")).fetchall() + ... conn.execute(text("SELECT * FROM users")).fetchall() [(0, 'User 6'), (1, 'User 7')] Use ``method`` to define a callable insertion method to do nothing @@ -3042,7 +3042,7 @@ def to_sql( For MySQL, a callable to update columns ``b`` and ``c`` if there's a conflict on a primary key. - >>> from sqlalchemy.dialects.mysql import insert + >>> from sqlalchemy.dialects.mysql import insert # doctest: +SKIP >>> def insert_on_conflict_update(table, conn, keys, data_iter): ... # update columns "b" and "c" on primary key conflict ... data = [dict(zip(keys, row)) for row in data_iter] @@ -3074,7 +3074,7 @@ def to_sql( 3 >>> with engine.connect() as conn: - ... conn.execute(text("SELECT * FROM integers")).fetchall() + ... conn.execute(text("SELECT * FROM integers")).fetchall() [(1,), (None,), (2,)] """ # noqa: E501 from pandas.io import sql