prestornado

Asynchronous PrestoDB DB-API for Tornado Web Server


License
Apache-2.0
Install
pip install prestornado==0.1.11

Documentation

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)