jianingy / prestornado

Asynchronous PrestoDB DB-API for Tornado Web Server

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Prestornado

Asynchronous PrestoDB DB-API for Tornado Web Server

This is a port based on dropbox's PyHive with requests been replaced with tornado's AsyncHTTPClient

Caveat

  • Optional PEP-0249 API next() has not been implemented yet :(

Example

from tornado.gen import coroutine
from prestornado import presto
import tornado.ioloop


@coroutine
def run_once():
    cursor = presto.connect('prestodb').cursor()
    yield cursor.execute('SELECT 1 + 1')
    while True:
        ret = yield cursor.poll()
        if not ret:
            break
        print ret['stats']['state']
    ret = yield cursor.fetchall()
    print 'RESULT:', ret

io_loop = tornado.ioloop.IOLoop.instance()
io_loop.run_sync(run_once)

About

Asynchronous PrestoDB DB-API for Tornado Web Server

License:Other


Languages

Language:Python 90.9%Language:Shell 9.1%