-
-
Notifications
You must be signed in to change notification settings - Fork 18.4k
BUG: Executing SQL containing non-escaped percent sign fails without parameters #34211
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
Comments
john-bodley
pushed a commit
to john-bodley/pandas
that referenced
this issue
May 16, 2020
5 tasks
john-bodley
pushed a commit
to john-bodley/pandas
that referenced
this issue
May 16, 2020
#11896 may be related |
@mroeschke I'm uncertain whether #11896 is the same issue and I'm unable to repo the MySQL example using the |
john-bodley
pushed a commit
to john-bodley/pandas
that referenced
this issue
May 17, 2020
john-bodley
pushed a commit
to john-bodley/pandas
that referenced
this issue
May 17, 2020
john-bodley
pushed a commit
to john-bodley/pandas
that referenced
this issue
May 19, 2020
john-bodley
pushed a commit
to john-bodley/pandas
that referenced
this issue
May 19, 2020
john-bodley
pushed a commit
to john-bodley/pandas
that referenced
this issue
May 19, 2020
john-bodley
pushed a commit
to john-bodley/pandas
that referenced
this issue
May 20, 2020
3 tasks
1 task
5 tasks
fixed by #34212 |
3 tasks
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I have checked that this issue has not already been reported.
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
raises the follow exception:
Problem description
Many DB-APIs (MySQL, PyHive, etc.) when executing a statement explicitly check whether the optional parameters are/are not explicitly
None
(as opposed to falsy) prior to substitution. The SQL statements in Pandas are executed via the SQLAlchemy connection (per here) resulting inparameters
of typeNoneType
being translated into an empty dictionary which can be problematic for the checks.Many of these DB-APIs use the
%
operator for applying the parameters which is problematic if no parameters are specified and the SQL statement contains the%
character (common in LIKE operator). One could modify their SQL by escaping the%
percent character however the preferred fix is merely to leverage SQLAlchemy's execution_options settingno_parameters=True
per,which ensures that falsy parameters will not pass the parameters to the DB-API resulting in parameters being
None
and thus no parameter formatting will be attempted.Expected Output
Output of
pd.show_versions()
[paste the output of
pd.show_versions()
here leaving a blank line after the details tag]The text was updated successfully, but these errors were encountered: