Tornado异步MySQL驱动程序[Fork of TormySQL]
mytor的Python项目详细描述
关于
Mytor-提供了一个基于未来龙卷风的API和Greenlet 对mysql的无阻塞访问。
安装
pip install mytor
示例
import mytor from tornado.ioloop import IOLoop from tornado.gen import coroutine pool = mytor.ConnectionPool( max_connections = 20, #max open connections idle_seconds = 7200, #conntion idle timeout time, 0 is not timeout host = "127.0.0.1", user = "root", passwd = "secret", db = "test", charset = "utf8" ) @coroutine def test(): with (yield pool.Connection()) as conn: with conn.cursor() as cursor: yield cursor.execute("SELECT * FROM test") datas = cursor.fetchall() print datas yield pool.close() IOLoop.current().run_sync(test)