Skip to content
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

"bad argument to internal function" with sql_mode="NO_BACKSLASH_ESCAPES" on 5.7 client #121

Open
kennethreitz opened this issue Oct 24, 2016 · 1 comment

Comments

@kennethreitz
Copy link

In 5.7.6+, mysql_real_escape_string() will error if the NO_BACKSLASH_ESCAPES SQL mode is enabled. Instead, mysql_real_escape_string_quote() must be used. See the note at https://dev.mysql.com/doc/refman/5.7/en/mysql-real-escape-string.html for more information:

To reproduce:

# python
Python 2.7.12 (default, Jul  1 2016, 15:12:24) 
[GCC 5.4.0 20160609] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import _mysql
>>> m=_mysql.connect(...)
>>> m.escape_string("foobar")
'foobar'
>>> m.query("SET SESSION sql_mode='NO_BACKSLASH_ESCAPES'")
>>> m.escape_string("foobar")
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
SystemError: ../Objects/stringobject.c:3903: bad argument to internal function
@nicktimko
Copy link

Resolved upstream. PyMySQL/mysqlclient#108

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants