Skip to content

CLN: turn pandas.io.sql into a submodule - #71966

Open
fangchenli wants to merge 3 commits into
pandas-dev:mainfrom
fangchenli:cln-sql-package
Open

fangchenli wants to merge 3 commits into
pandas-dev:mainfrom
fangchenli:cln-sql-package

Conversation

@fangchenli

@fangchenli fangchenli commented Nov 8, 2026 •

Copy link
Copy Markdown
Member

Split pandas/io/sql.py (~3,100 lines) into a submodule with one file per backend. This is a pure move with no behavior change, done as groundwork for follow-up work on the DBAPI2 fallback.

  • api.py: read_sql*, to_sql, has_table, get_schema, pandasSQL_builder
  • base.py: PandasSQL, SQLTable, shared helpers
  • sqla.py, adbc.py, sqlite.py: one module per backend

pandas.io.sql re-exports every public name, so existing imports keep working. The three helpers shared across modules drop their leading underscore to satisfy the private-import check. Private names are no longer reachable as pandas.io.sql._X, and monkeypatching should now target the defining module (e.g. pandas.io.sql.api).

  • closes #xxxx (Replace xxxx with the GitHub issue number)

  • Tests added and passed if fixing a bug or adding a new feature

  • All code checks passed.

  • Added type annotations to new arguments/methods/functions.

  • Added an entry in the latest doc/source/whatsnew/vX.X.X.rst file if fixing a bug or adding a new feature.

  • I have reviewed and followed all the contribution guidelines
    Check exactly one of the following, per the automated contributions policy:

  • I did not use AI to develop this pull request.

  • I used AI to develop this pull request. I prompted it to follow AGENTS.md, I have reviewed and understood every change, and I have described above how I used it and exactly which tool, model version, and effort setting — e.g. claude opus 4.8 (xhigh), not just claude.

🤖 Generated with Claude Code

fangchenli and others added 2 commits November 8, 2026 06:38
Split the 3,100-line pandas/io/sql.py into a package, one module per
backend, as a pure move with no behavior change:

- api.py: read_sql*, to_sql, has_table, get_schema, pandasSQL_builder
- base.py: PandasSQL, SQLTable, result-wrapping and date-parsing helpers
- sqla.py: SQLDatabase, BaseEngine, SQLAlchemyEngine, get_engine
- adbc.py: ADBCDatabase
- sqlite.py: SQLiteDatabase, SQLiteTable

pandas/io/sql/__init__.py re-exports every public name the old module
defined, plus DatabaseError, so `from pandas.io.sql import ...` keeps
working. Helpers shared across modules lose their leading underscore
(wrap_result, parse_date_columns, get_unicode_name) to satisfy the
private-import-across-module check.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The reportGeneralTypeIssues exclude list still named the deleted
pandas/io/sql.py. Exclude only the three new modules that inherit its
pre-existing errors (base.py, sqla.py, sqlite.py); api.py, adbc.py and
__init__.py are clean and stay checked.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@fangchenli fangchenli changed the title CLN: turn pandas.io.sql into a package CLN: turn pandas.io.sql into a submodule Nov 8, 2026
@fangchenli fangchenli added IO SQL to_sql, read_sql, read_sql_query Clean labels Nov 8, 2026

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Clean IO SQL to_sql, read_sql, read_sql_query

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant