Skip to content

DOC: added adbc connection in con parameter of to_sql and example of its usage #59198

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Jul 8, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 18 additions & 1 deletion pandas/core/generic.py
Original file line number Diff line number Diff line change
Expand Up @@ -2779,7 +2779,8 @@ def to_sql(
----------
name : str
Name of SQL table.
con : sqlalchemy.engine.(Engine or Connection) or sqlite3.Connection
con : ADBC connection, sqlalchemy.engine.(Engine or Connection) or sqlite3.Connection
ADBC provides high performance I/O with native type support, where available.
Using SQLAlchemy makes it possible to use any DB supported by that
library. Legacy support is provided for sqlite3.Connection objects. The user
is responsible for engine disposal and connection closure for the SQLAlchemy
Expand Down Expand Up @@ -2966,6 +2967,22 @@ def to_sql(
>>> with engine.connect() as conn:
... conn.execute(text("SELECT * FROM integers")).fetchall()
[(1,), (None,), (2,)]

.. versionadded:: 2.2.0

pandas now supports writing via ADBC drivers

>>> df = pd.DataFrame({'name' : ['User 10', 'User 11', 'User 12']})
>>> df
name
0 User 10
1 User 11
2 User 12

>>> from adbc_driver_sqlite import dbapi # doctest:+SKIP
>>> with dbapi.connect("sqlite://") as conn: # doctest:+SKIP
... df.to_sql(name="users", con=conn)
3
""" # noqa: E501
from pandas.io import sql

Expand Down