Skip to content

Deprecation Warning: The Connection.run_callable() method is deprecated #40825

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

Closed
3 tasks done
tommyjcarpenter opened this issue Apr 7, 2021 · 8 comments
Closed
3 tasks done
Labels
Bug Closing Candidate May be closeable, needs more eyeballs Dependencies Required and optional dependencies IO SQL to_sql, read_sql, read_sql_query

Comments

@tommyjcarpenter
Copy link

tommyjcarpenter commented Apr 7, 2021

  • I have checked that this issue has not already been reported.
    (I tried searching all issues for SADeprecationWarning but didn't find this particular issue)

  • I have confirmed this bug exists on the latest version of pandas.
    We pin to: "pandas>=1.2.0, <2.0.0"

  • (optional) I have confirmed this bug exists on the master branch of pandas.
    Yes it's on master: https://github.com/pandas-dev/pandas/blob/master/pandas/io/sql.py#L1644


Code Sample, a copy-pastable example

It is hard to show a pastable example because it relies on a connection to a database. Basically any usage of:

with get_engine(dbname).connect() as conn:
      df = pd.read_sql(stmt, conn, **kwargs)
      return df

Note that the code surrounding pandas is using a context manager (conn)

Problem description

It reports:

  /Users/tommycarpenter/Development/python-indexapi/.tox/py37/lib/python3.7/site-packages/pandas/io/sql.py:1430: SADeprecationWarning: The Connection.run_callable() method is deprecated and will be removed in a future release.  Invoke the callable function directly, passing the Connection. (deprecated since: 1.4)
    self.connectable.dialect.has_table, name, schema or self.meta.schema

Looking at that file, at that line, shows:

# pandas/io/sql.py

    def has_table(self, name, schema=None):
        return self.connectable.run_callable(
            self.connectable.dialect.has_table, name, schema or self.meta.schema
        )

Which is a different line number than master, bnut its still there on master: https://github.com/pandas-dev/pandas/blob/master/pandas/io/sql.py#L1644

@tommyjcarpenter tommyjcarpenter added Bug Needs Triage Issue that has not been reviewed by a pandas team member labels Apr 7, 2021
@lithomas1
Copy link
Member

lithomas1 commented Apr 7, 2021

Can you please paste your pd.show_versions? IIRC, this was patched on master for sqlalchemy >= 1.4, and was backported for the upcoming pandas 1.2.4 release?

EDIT: Small Typo. Meant >= 1.4 not > 1.4.

@tommyjcarpenter
Copy link
Author

tommyjcarpenter commented Apr 7, 2021

@lithomas1 I appear to be using the latest release of pandas (and the code is still in the master branch as showed above)

when you say > 1.4, do you mean >=1.5 or >1.4.0? It would appear I am using 1.4.6 of SA.

INSTALLED VERSIONS
------------------
commit           : f2c8480af2f25efdbd803218b9d87980f416563e
python           : 3.7.9.final.0
python-bits      : 64
OS               : Darwin
OS-release       : 20.3.0
Version          : Darwin Kernel Version 20.3.0: Thu Jan 21 00:07:06 PST 2021; root:xnu-7195.81.3~1/RELEASE_X86_64
machine          : x86_64
processor        : i386
byteorder        : little
LC_ALL           : None
LANG             : en_US.UTF-8
LOCALE           : en_US.UTF-8

pandas           : 1.2.3
numpy            : 1.20.2
pytz             : 2021.1
dateutil         : 2.8.1
pip              : 20.3.3
setuptools       : 51.3.3
Cython           : None
pytest           : 6.2.3
hypothesis       : None
sphinx           : None
blosc            : None
feather          : None
xlsxwriter       : None
lxml.etree       : 4.6.3
html5lib         : None
pymysql          : 1.0.2
psycopg2         : None
jinja2           : 2.11.3
IPython          : None
pandas_datareader: 0.9.0
bs4              : None
bottleneck       : None
fsspec           : None
fastparquet      : None
gcsfs            : None
matplotlib       : None
numexpr          : None
odfpy            : None
openpyxl         : None
pandas_gbq       : None
pyarrow          : None
pyxlsb           : None
s3fs             : None
scipy            : 1.6.2
sqlalchemy       : 1.4.6
tables           : None
tabulate         : 0.8.9
xarray           : None
xlrd             : None
xlwt             : None
numba            : None

@jreback
Copy link
Contributor

jreback commented Apr 7, 2021

pls try on master

@tommyjcarpenter
Copy link
Author

tommyjcarpenter commented Apr 7, 2021

@jreback we get from pip; as a pip dependency. AFAIK we pip the latest.

I think the answer I've heard here is "this is fixed in a currently-unreleased pandas".

@lithomas1
Copy link
Member

Yeah, the code path on master should be only exectued for sqlalchemy < 1.4.

@tommyjcarpenter
Copy link
Author

@lithomas1 so when 1.2.4 is released, these deprecation warnings should go away after pipping 1.2.4, given any SA 1.4.0 or greater?

@lithomas1 lithomas1 added IO SQL to_sql, read_sql, read_sql_query Dependencies Required and optional dependencies Closing Candidate May be closeable, needs more eyeballs and removed Needs Triage Issue that has not been reviewed by a pandas team member labels Apr 7, 2021
@lithomas1
Copy link
Member

lithomas1 commented Apr 7, 2021

Yes. There is still some work to be done to be compatible with the upcoming sqlalchemy 2.0(#40686), but the SADeprecationWarnings should go away.

@tommyjcarpenter
Copy link
Author

Thank you.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Closing Candidate May be closeable, needs more eyeballs Dependencies Required and optional dependencies IO SQL to_sql, read_sql, read_sql_query
Projects
None yet
Development

No branches or pull requests

3 participants