Description
-
[ x] I have checked that this issue has not already been reported.
-
[ x] I have confirmed this bug exists on the latest version of pandas.
-
(optional) I have confirmed this bug exists on the master branch of pandas.
Note: Please read this guide detailing how to provide the necessary information for us to reproduce your bug.
Code Sample, a copy-pastable example
import pandas as pd
import sqlalchemy
from config import credentials
engine = sqlalchemy.create_engine(
"mysql+mysqldb://%(user)s:%(password)s@%(host)s/%(default)s" % credentials,
echo=False,
)
sql_query = r"""
SELECT
time_string,
STR_TO_DATE(time_string, '%%d/%%m/%%Y'),
data
FROM
test_table
"""
data = pd.read_sql_query(sql_query, engine)
print(data)
Problem description
In Pandas 1.0.5, '%' in a sql query needed to be escaped as '%%'.
This changes in 1.1.0, but I couldn't see any relevant comment in the release notes. (The behaviour is the same in 1.1.1).
My feeling is that the new behaviour is actually better, but this still seems to be a regression (or an undocumented change).
Expected Output
Output of pd.show_versions()
INSTALLED VERSIONS
commit : d9fff27
python : 3.7.8.final.0
python-bits : 64
OS : Darwin
OS-release : 17.7.0
Version : Darwin Kernel Version 17.7.0: Wed Feb 27 00:43:23 PST 2019; root:xnu-4570.71.35~1/RELEASE_X86_64
machine : x86_64
processor : i386
byteorder : little
LC_ALL : None
LANG : en_GB.UTF-8
LOCALE : en_GB.UTF-8
pandas : 1.1.0
numpy : 1.18.5
pytz : 2018.9
dateutil : 2.8.0
pip : 20.2.2
setuptools : 40.8.0
Cython : None
pytest : None
hypothesis : None
sphinx : None
blosc : None
feather : None
xlsxwriter : 1.2.9
lxml.etree : None
html5lib : None
pymysql : None
psycopg2 : None
jinja2 : None
IPython : None
pandas_datareader: None
bs4 : None
bottleneck : None
fsspec : None
fastparquet : None
gcsfs : None
matplotlib : None
numexpr : None
odfpy : None
openpyxl : None
pandas_gbq : None
pyarrow : None
pytables : None
pyxlsb : None
s3fs : None
scipy : None
sqlalchemy : 1.3.17
tables : None
tabulate : None
xarray : None
xlrd : 1.2.0
xlwt : None
numba : None