@@ -2999,7 +2999,7 @@ def to_sql(
29992999 3
30003000 >>> from sqlalchemy import text
30013001 >>> with engine.connect() as conn:
3002- ... conn.execute(text("SELECT * FROM users")).fetchall()
3002+ ... conn.execute(text("SELECT * FROM users")).fetchall()
30033003 [(0, 'User 1'), (1, 'User 2'), (2, 'User 3')]
30043004
30053005 An `sqlalchemy.engine.Connection` can also be passed to `con`:
@@ -3016,7 +3016,7 @@ def to_sql(
30163016 >>> df2.to_sql(name='users', con=engine, if_exists='append')
30173017 2
30183018 >>> with engine.connect() as conn:
3019- ... conn.execute(text("SELECT * FROM users")).fetchall()
3019+ ... conn.execute(text("SELECT * FROM users")).fetchall()
30203020 [(0, 'User 1'), (1, 'User 2'), (2, 'User 3'),
30213021 (0, 'User 4'), (1, 'User 5'), (0, 'User 6'),
30223022 (1, 'User 7')]
@@ -3027,7 +3027,7 @@ def to_sql(
30273027 ... index_label='id')
30283028 2
30293029 >>> with engine.connect() as conn:
3030- ... conn.execute(text("SELECT * FROM users")).fetchall()
3030+ ... conn.execute(text("SELECT * FROM users")).fetchall()
30313031 [(0, 'User 6'), (1, 'User 7')]
30323032
30333033 Use ``method`` to define a callable insertion method to do nothing
@@ -3040,13 +3040,14 @@ def to_sql(
30403040 ... stmt = insert(table.table).values(data).on_conflict_do_nothing(index_elements=["a"])
30413041 ... result = conn.execute(stmt)
30423042 ... return result.rowcount
3043- >>> df_conflict.to_sql(name="conflict_table", con=conn, if_exists="append", method=insert_on_conflict_nothing) # doctest: +SKIP
3043+ >>> df_conflict.to_sql(name="conflict_table", con=conn, if_exists="append", # noqa: F821
3044+ ... method=insert_on_conflict_nothing) # doctest: +SKIP
30443045 0
30453046
30463047 For MySQL, a callable to update columns ``b`` and ``c`` if there's a conflict
30473048 on a primary key.
30483049
3049- >>> from sqlalchemy.dialects.mysql import insert
3050+ >>> from sqlalchemy.dialects.mysql import insert # noqa: F811
30503051 >>> def insert_on_conflict_update(table, conn, keys, data_iter):
30513052 ... # update columns "b" and "c" on primary key conflict
30523053 ... data = [dict(zip(keys, row)) for row in data_iter]
@@ -3057,7 +3058,8 @@ def to_sql(
30573058 ... stmt = stmt.on_duplicate_key_update(b=stmt.inserted.b, c=stmt.inserted.c)
30583059 ... result = conn.execute(stmt)
30593060 ... return result.rowcount
3060- >>> df_conflict.to_sql(name="conflict_table", con=conn, if_exists="append", method=insert_on_conflict_update) # doctest: +SKIP
3061+ >>> df_conflict.to_sql(name="conflict_table", con=conn, if_exists="append", # noqa: F821
3062+ ... method=insert_on_conflict_update) # doctest: +SKIP
30613063 2
30623064
30633065 Specify the dtype (especially useful for integers with missing values).
@@ -3078,7 +3080,7 @@ def to_sql(
30783080 3
30793081
30803082 >>> with engine.connect() as conn:
3081- ... conn.execute(text("SELECT * FROM integers")).fetchall()
3083+ ... conn.execute(text("SELECT * FROM integers")).fetchall()
30823084 [(1,), (None,), (2,)]
30833085 """ # noqa: E501
30843086 from pandas .io import sql
0 commit comments