BUG: .to_sql(method=mysql_update_on_dupe_key) fails because of change from 1.3.1 to 1.4.2. #46891
Closed
3 tasks done
Labels
Bug
IO SQL
to_sql, read_sql, read_sql_query
Needs Triage
Issue that has not been reviewed by a pandas team member
Milestone
Pandas version checks
I have checked that this issue has not already been reported.
I have confirmed this bug exists on the latest version of pandas.
I have confirmed this bug exists on the main branch of pandas.
Reproducible Example
Issue Description
df.to_sql fails when a method is passed for updating on duplicate keys. New code was added to check the total_inserted against the num_inserted between 1.3.1 and 1.4.2. I suppose I should have reproducible code that would show a sqllite table creation, etc.. Hopefully this is enough code to understand my bug report.
A TypeError is returned:
Because this code block at line 951 in sql.py.
If I change it to the following, it works.:
Expected Behavior
Not raise a TypeError when a method is passed.
Change line 951 in sql.py.
if num_inserted is None or callable(num_inserted):
Installed Versions
Working pd.show_versions:
pandas : 1.3.1
numpy : 1.20.3
pytz : 2021.1
dateutil : 2.8.2
pip : 21.2.2
setuptools : 52.0.0.post20210125
Cython : None
pytest : 6.2.4
hypothesis : None
sphinx : None
blosc : None
feather : None
xlsxwriter : None
lxml.etree : None
html5lib : None
pymysql : 1.0.2
psycopg2 : None
jinja2 : None
IPython : None
pandas_datareader: None
bs4 : None
bottleneck : 1.3.2
fsspec : None
fastparquet : None
gcsfs : None
matplotlib : None
numexpr : 2.7.3
odfpy : None
openpyxl : 3.0.7
pandas_gbq : None
pyarrow : 4.0.0
pyxlsb : None
s3fs : None
scipy : 1.6.2
sqlalchemy : 1.4.22
tables : None
tabulate : None
xarray : None
xlrd : None
xlwt : None
numba : None
Not working pd.show_versions():
Failed:
The text was updated successfully, but these errors were encountered: