Skip to content

Commit 61c5fbf

Browse files
authored
DOC: added adbc connection in con parameter of to_sql and example of its usage (#59198)
* doc: to_sql docs should mention ADBC #59095 * remove two blank lines at the end of docstring. * added one more space in in-line comments of example.
1 parent 1429727 commit 61c5fbf

File tree

1 file changed

+18
-1
lines changed

1 file changed

+18
-1
lines changed

pandas/core/generic.py

+18-1
Original file line numberDiff line numberDiff line change
@@ -2779,7 +2779,8 @@ def to_sql(
27792779
----------
27802780
name : str
27812781
Name of SQL table.
2782-
con : sqlalchemy.engine.(Engine or Connection) or sqlite3.Connection
2782+
con : ADBC connection, sqlalchemy.engine.(Engine or Connection) or sqlite3.Connection
2783+
ADBC provides high performance I/O with native type support, where available.
27832784
Using SQLAlchemy makes it possible to use any DB supported by that
27842785
library. Legacy support is provided for sqlite3.Connection objects. The user
27852786
is responsible for engine disposal and connection closure for the SQLAlchemy
@@ -2966,6 +2967,22 @@ def to_sql(
29662967
>>> with engine.connect() as conn:
29672968
... conn.execute(text("SELECT * FROM integers")).fetchall()
29682969
[(1,), (None,), (2,)]
2970+
2971+
.. versionadded:: 2.2.0
2972+
2973+
pandas now supports writing via ADBC drivers
2974+
2975+
>>> df = pd.DataFrame({'name' : ['User 10', 'User 11', 'User 12']})
2976+
>>> df
2977+
name
2978+
0 User 10
2979+
1 User 11
2980+
2 User 12
2981+
2982+
>>> from adbc_driver_sqlite import dbapi # doctest:+SKIP
2983+
>>> with dbapi.connect("sqlite://") as conn: # doctest:+SKIP
2984+
... df.to_sql(name="users", con=conn)
2985+
3
29692986
""" # noqa: E501
29702987
from pandas.io import sql
29712988

0 commit comments

Comments
 (0)