PyMySQL/Tornado-MySQL

What's the suitable way to know whether the sql is executed successfully or not?

MingdaMingda opened this issue · 1 comments

I am not familiar with futures mechanism. so ask for help...
If the sql don't execute successfully, how can i get err-no and err-message from mysql?
thanks~

Now I do it by this way:

import logging
from tornado import ioloop, gen
from tornado_mysql import pools

dbpool = pools.Pool(...)

@gen.coroutine
def run_sql(sql):
    success = False
    try:
        cur = yield dbpool.execute(sql)
        success = True
    except:
        logging.error('mysql execution error')

    if success:
        # do sth.