Skip to main content

Pure Python MySQL Driver for Tornado

Project description

This package contains a fork of PyMySQL supporting Tornado.



#!/usr/bin/env python
from __future__ import print_function

from tornado import ioloop, gen
import tornado_mysql

def main():
    conn = yield tornado_mysql.connect(host='', port=3306, user='root', passwd='', db='mysql')
    cur = conn.cursor()
    yield cur.execute("SELECT Host,User FROM user")
    for row in cur:



#!/usr/bin/env python
from __future__ import print_function

from tornado import ioloop, gen
from tornado_mysql import pools

pools.DEBUG = True

POOL = pools.Pool(
    dict(host='', port=3306, user='root', passwd='', db='mysql'),

def worker(n):
    for i in range(10):
        t = 1
        print(n, "sleeping", t, "seconds")
        cur = yield POOL.execute("SELECT SLEEP(%s)", (t,))
        print(n, cur.fetchall())

def main():
    workers = [worker(i) for i in range(10)]
    yield workers



  • Python – one of the following:
  • MySQL Server – one of the following:


The last stable release is available on PyPI and can be installed with pip:

$ pip install Tornado-MySQL

Test Suite

If you would like to run the test suite, first copy the file .travis.databases.json to tornado_mysql/tests/databases.json and edit the new file to match your MySQL configuration:

$ cp .travis.databases.json tornado_mysql/tests/databases.json
$ $EDITOR tornado_mysql/tests/databases.json

To run all the tests, execute the script

$ python

A tox.ini file is also provided for conveniently running tests on multiple Python versions:

$ tox


PyMySQL is released under the MIT License. See LICENSE for more information.

Project details

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Files for Tornado-MySQL, version 0.5.1
Filename, size File type Python version Upload date Hashes
Filename, size Tornado_MySQL-0.5.1-py2.py3-none-any.whl (66.5 kB) File type Wheel Python version 2.7 Upload date Hashes View
Filename, size Tornado-MySQL-0.5.1.tar.gz (56.0 kB) File type Source Python version None Upload date Hashes View

Supported by

Pingdom Pingdom Monitoring Google Google Object Storage and Download Analytics Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN DigiCert DigiCert EV certificate StatusPage StatusPage Status page