handlers_for_tables.py 404 字节
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13
import json

import aiomysql
import tornado


class EmpHandler(tornado.web.RequestHandler):

    async def get(self, *args, **kwargs):
        async with self.settings['mysql'].cursor(aiomysql.DictCursor) as cursor:
            await cursor.execute("select eno as no, ename as name, job, sal, intro from tb_emp")
            emps = list(await cursor.fetchall())
            self.finish(json.dumps(emps))