Skip to content

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

@MingdaMingda

Description

@MingdaMingda

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.

Metadata

Metadata

Assignees

No one assigned

    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