Skip to content

Asynchronous PrestoDB DB-API for Tornado Web Server

License

Notifications You must be signed in to change notification settings

jianingy/prestornado

Repository files navigation

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

Resources

License

Stars

Watchers

Forks

Packages

No packages published