Wildcard problem? Can't write a "like" query

Asked by DT

Wildcard problem? Simple to run like query interactively from the prompt in MySQL, such as "SELECT col FROM table WHERE col LIKE '%assign%';"

Try to run this same query via python:

sql_phrase = "SELECT col FROM table WHERE col LIKE '%%assign%%';"
cursor.execute(sql_phrase)

I get the error below. This seems to be something specific to using the wildcards around 'assign', can't search that string although it would be very helpful to do so. Is this a bug?

Traceback (most recent call last):
  File "judge_who.py", line 33, in <module>
    cursor.execute(sql_phrase)
  File "/usr/local/lib/python2.7/site-packages/mysql/connector/cursor.py", line 392, in execute
    self._handle_result(self._connection.cmd_query(stmt))
  File "/usr/local/lib/python2.7/site-packages/mysql/connector/cursor.py", line 316, in _handle_result
    self._handle_resultset()
  File "/usr/local/lib/python2.7/site-packages/mysql/connector/cursor.py", line 684, in _handle_resultset
    (self._rows, eof) = self._connection.get_rows()
  File "/usr/local/lib/python2.7/site-packages/mysql/connector/connection.py", line 451, in get_rows
    rows = self._protocol.read_text_result(self._socket, count)
  File "/usr/local/lib/python2.7/site-packages/mysql/connector/protocol.py", line 234, in read_text_result
    packet = sock.recv()
  File "/usr/local/lib/python2.7/site-packages/mysql/connector/network.py", line 169, in recv_plain
    raise errors.InterfaceError(errno=2013)
mysql.connector.errors.InterfaceError: 2013: Lost connection to MySQL server during query

Question information

Language:
English Edit question
Status:
Expired
For:
MySQL Connector/Python Edit question
Assignee:
No assignee Edit question
Last query:
Last reply:
Revision history for this message
Geert JM Vanderkelen (geertjmvdk) said :
#1

I can not reproduce this problem with SELECT * FROM mysql.user WHERE user LIKE '%root%'

Is this always reproducible? If so, please report a bug on bugs.mysql.com with a complete test case and more information about the tables.

Revision history for this message
DT (dougt901-2012) said :
#2

It's only reproducible through the connector specifically using the string match '%%assign%%' (the extra percents to escape out the % character).

I am working around this by adding a space after the first percents '%% assign%%', and then adding an 'OR' statement for other things that end in 'assign', for example '%% reassign%%'

Sounds like a bug.

Revision history for this message
Launchpad Janitor (janitor) said :
#3

This question was expired because it remained in the 'Open' state without activity for the last 15 days.