{"id":14969060,"url":"https://github.com/snower/tormysql","last_synced_at":"2025-04-04T13:13:31.976Z","repository":{"id":19505468,"uuid":"22752008","full_name":"snower/TorMySQL","owner":"snower","description":"The highest performance asynchronous MySQL driver by PyMySQL","archived":false,"fork":false,"pushed_at":"2021-01-11T11:01:13.000Z","size":214,"stargazers_count":307,"open_issues_count":3,"forks_count":63,"subscribers_count":13,"default_branch":"master","last_synced_at":"2025-04-04T13:13:27.601Z","etag":null,"topics":["asyncio","mariadb","mysql","pymysql","python","tornado"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/snower.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2014-08-08T09:00:28.000Z","updated_at":"2024-12-14T03:17:34.000Z","dependencies_parsed_at":"2022-08-23T17:21:18.023Z","dependency_job_id":null,"html_url":"https://github.com/snower/TorMySQL","commit_stats":null,"previous_names":[],"tags_count":28,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/snower%2FTorMySQL","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/snower%2FTorMySQL/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/snower%2FTorMySQL/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/snower%2FTorMySQL/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/snower","download_url":"https://codeload.github.com/snower/TorMySQL/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247182420,"owners_count":20897381,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["asyncio","mariadb","mysql","pymysql","python","tornado"],"created_at":"2024-09-24T13:41:04.143Z","updated_at":"2025-04-04T13:13:31.951Z","avatar_url":"https://github.com/snower.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# TorMySQL\n\n[![Build Status](https://travis-ci.org/snower/TorMySQL.svg?branch=master)](https://travis-ci.org/snower/TorMySQL)\n\nThe highest performance asynchronous MySQL driver.\n\nPyPI page: https://pypi.python.org/pypi/tormysql\n\n# About\n\nPresents a Future-based API and greenlet for non-blocking access to MySQL.\n\nSupport both [tornado](https://github.com/tornadoweb/tornado) and [asyncio](https://docs.python.org/3/library/asyncio.html).\n\n# Installation\n\n```\npip install TorMySQL\n```\n\n# Used Tornado\n\n## example pool\n\n```\nfrom tornado.ioloop import IOLoop\nfrom tornado import gen\nimport tormysql\n\npool = tormysql.ConnectionPool(\n    max_connections = 20, #max open connections\n    idle_seconds = 7200, #conntion idle timeout time, 0 is not timeout\n    wait_connection_timeout = 3, #wait connection timeout\n    host = \"127.0.0.1\",\n    user = \"root\",\n    passwd = \"TEST\",\n    db = \"test\",\n    charset = \"utf8\"\n)\n\n@gen.coroutine\ndef test():\n    with (yield pool.Connection()) as conn:\n        try:\n            with conn.cursor() as cursor:\n                yield cursor.execute(\"INSERT INTO test(id) VALUES(1)\")\n        except:\n            yield conn.rollback()\n        else:\n            yield conn.commit()\n\n        with conn.cursor() as cursor:\n            yield cursor.execute(\"SELECT * FROM test\")\n            datas = cursor.fetchall()\n\n    print datas\n    \n    yield pool.close()\n\nioloop = IOLoop.instance()\nioloop.run_sync(test)\n```\n\n## example helpers\n\n```\nfrom tornado.ioloop import IOLoop\nfrom tornado import gen\nimport tormysql\n\npool = tormysql.helpers.ConnectionPool(\n    max_connections = 20, #max open connections\n    idle_seconds = 7200, #conntion idle timeout time, 0 is not timeout\n    wait_connection_timeout = 3, #wait connection timeout\n    host = \"127.0.0.1\",\n    user = \"root\",\n    passwd = \"TEST\",\n    db = \"test\",\n    charset = \"utf8\"\n)\n\n@gen.coroutine\ndef test():\n    tx = yield pool.begin()\n    try:\n        yield tx.execute(\"INSERT INTO test(id) VALUES(1)\")\n    except:\n        yield tx.rollback()\n    else:\n        yield tx.commit()\n\n    cursor = yield pool.execute(\"SELECT * FROM test\")\n    datas = cursor.fetchall()\n\n    print datas\n\n    yield pool.close()\n\nioloop = IOLoop.instance()\nioloop.run_sync(test)\n```\n\n# Used asyncio alone\n\n## example pool\n\n```\nfrom asyncio import events\nimport tormysql\n\npool = tormysql.ConnectionPool(\n   max_connections = 20, #max open connections\n   idle_seconds = 7200, #conntion idle timeout time, 0 is not timeout\n   wait_connection_timeout = 3, #wait connection timeout\n   host = \"127.0.0.1\",\n   user = \"root\",\n   passwd = \"TEST\",\n   db = \"test\",\n   charset = \"utf8\"\n)\n\nasync def test():\n   async with await pool.Connection() as conn:\n       try:\n           async with conn.cursor() as cursor:\n               await cursor.execute(\"INSERT INTO test(id) VALUES(1)\")\n       except:\n           await conn.rollback()\n       else:\n           await conn.commit()\n\n       async with conn.cursor() as cursor:\n           await cursor.execute(\"SELECT * FROM test\")\n           datas = cursor.fetchall()\n\n   print(datas)\n\n   await pool.close()\n\nioloop = events.get_event_loop()\nioloop.run_until_complete(test)\n```\n\n## example helpers\n\n```\nfrom asyncio import events\nimport tormysql\n\npool = tormysql.helpers.ConnectionPool(\n   max_connections = 20, #max open connections\n   idle_seconds = 7200, #conntion idle timeout time, 0 is not timeout\n   wait_connection_timeout = 3, #wait connection timeout\n   host = \"127.0.0.1\",\n   user = \"root\",\n   passwd = \"TEST\",\n   db = \"test\",\n   charset = \"utf8\"\n)\n\nasync def test():\n   async with await pool.begin() as tx:\n       await tx.execute(\"INSERT INTO test(id) VALUES(1)\")\n\n   cursor = await pool.execute(\"SELECT * FROM test\")\n   datas = cursor.fetchall()\n\n   print(datas)\n\n   await pool.close()\n\nioloop = events.get_event_loop()\nioloop.run_until_complete(test)\n```\n\n# Resources\n\nYou can read [PyMySQL Documentation](http://pymysql.readthedocs.io/) online for more information.\n\n# License\n\nTorMySQL uses the MIT license, see LICENSE file for the details.","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsnower%2Ftormysql","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsnower%2Ftormysql","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsnower%2Ftormysql/lists"}