Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

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

Copy link
Copy link
Closed
@dzuelke

Description

@dzuelke
Issue body actions

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

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions

    Morty Proxy This is a proxified and sanitized view of the page, visit original site.