Open
Description
Feature Type
-
Adding new functionality to pandas
-
Changing existing functionality in pandas
-
Removing existing functionality in pandas
Problem Description
It would be a nice QoL upgrade to be able to pass any additional, optional, params to calls to pandas.read_sql
which will be passed to any call to sqlalchemy.create_engine
. My particular use case is that I would like to pass echo=True
to pd.read_sql
so that the executed statements would be logged automatically, when using a connection string rather than an existing SQLAlchemy Connection.
Feature Description
Add a new parameter to pandas.read_sql
, either connect_kwargs
or echo
. I'll provide an example for adding connect_kwargs
# pandas/pandas/io/sql.py
class SQLDatabase(..., **connect_kwargs):
...
if isinstance(con, str): # line 1576
con = create_engine(con, **connect_kwargs)
...
def pandasSQL_builder(..., **connect_kwargs) -> PandasSQL:
...
if sqlalchemy is not None and isinstance(con, (str, sqlalchemy.engine.Connectable)): # line 850
return SQLDatabase(con, schema, need_transaction, **connect_kwargs)
...
def read_sql(..., **connect_kwargs):
...
with pandasSQL_builder(con, **connect_kwargs) as pandas_sql: # line 652
...
...
Alternative Solutions
No alternative solution, besides using a SQLAlchemy connectable rather than the proposed edits.
Additional Context
No response