PyMySQL/Tornado-MySQL

DictCursor causing AttributeError: 'Connection' object has no attribute 'errorhandler'

kkoston opened this issue · 6 comments

Tried passing to pool.execute and also via connect_kwargs to the pool constructor.

HTTPServerRequest(protocol='http', host='127.0.0.1:8888', method='GET', uri='/huddle/news', version='HTTP/1.1', remote_ip='127.0.0.1', headers={'Accept-Language': 'en-US,en;q=0.8,pl;q=0.6', 'Accept-Encoding': 'gzip, deflate, sdch', 'Host': '127.0.0.1:8888', 'Accept': 'text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8', 'User-Agent': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_11_5) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/51.0.2704.84 Safari/537.36', 'Connection': 'keep-alive', 'Cookie': 'rg_cookie_session_id=2073182434', 'Cache-Control': 'max-age=0', 'Upgrade-Insecure-Requests': '1'})
Traceback (most recent call last):
  File "/Library/Python/2.7/site-packages/tornado/web.py", line 1445, in _execute
    result = yield result
  File "/Library/Python/2.7/site-packages/tornado/gen.py", line 1008, in run
    value = future.result()
  File "/Library/Python/2.7/site-packages/tornado/concurrent.py", line 232, in result
    raise_exc_info(self._exc_info)
  File "/Library/Python/2.7/site-packages/tornado/gen.py", line 1014, in run
    yielded = self.gen.throw(*exc_info)
  File "/Users/kkoston/dev/thehuddle/api/huddle/news.py", line 15, in get
    cur = yield db.HUDDLE.execute(sql)
  File "/Library/Python/2.7/site-packages/tornado/gen.py", line 1008, in run
    value = future.result()
  File "/Library/Python/2.7/site-packages/tornado/concurrent.py", line 232, in result
    raise_exc_info(self._exc_info)
  File "/Library/Python/2.7/site-packages/tornado/gen.py", line 1017, in run
    yielded = self.gen.send(value)
  File "/Library/Python/2.7/site-packages/Tornado_MySQL-0.5.1-py2.7.egg/tornado_mysql/pools.py", line 125, in execute
    cur = conn.cursor(cursor)
  File "/Library/Python/2.7/site-packages/Tornado_MySQL-0.5.1-py2.7.egg/tornado_mysql/connections.py", line 693, in cursor
    return self.cursorclass(self)
  File "/Library/Python/2.7/site-packages/MySQLdb/cursors.py", line 86, in __init__
    self.errorhandler = connection.errorhandler
AttributeError: 'Connection' object has no attribute 'errorhandler'
ERROR:tornado.access:500 GET /huddle/news (127.0.0.1) 205.46ms

Are you passing MySQLdb's cursor to pool.execute?
It's impossible.

Yes. I am passing the cursor to pool.execute. According to what I can see in the code (pools.py line 113) it should be possible.
Also tried passing the cursor to Pool constructor (pools.py, line 28) connect_kwargs - MySQL's connect function allows passing it via "cursorclass" argument. Getting exactly the same error here.

According to what I can see in the code (pools.py line 113) it should be possible.

No.

Hmm, the what is the reason for it being there? :)

async code and sync code is incompatible.
That's very basic.

I realize that blocking code is not compatible with non-blocking code but somehow do not see how this relates to my question. Is using DictCursor a problem? If so, then why 'cursor' argument was added to the execute method?