tormysql


Nametormysql JSON
Version 0.4.3 PyPI version JSON
download
home_pagehttps://github.com/snower/TorMySQL
SummaryTornado asynchronous MySQL Driver
upload_time2021-01-11 11:00:28
maintainer
docs_urlNone
authorsnower, mosquito
requires_python
licenseMIT
keywords tornado mysql
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI
coveralls test coverage No coveralls.
            TorMySQL
========

|Build Status|

The highest performance asynchronous MySQL driver.

PyPI page: https://pypi.python.org/pypi/tormysql

About
=====

Presents a Future-based API and greenlet for non-blocking access to
MySQL.

Support both `tornado <https://github.com/tornadoweb/tornado>`__ and
`asyncio <https://docs.python.org/3/library/asyncio.html>`__.

Installation
============

::

    pip install TorMySQL

Used Tornado
============

example pool
------------

::

    from tornado.ioloop import IOLoop
    from tornado import gen
    import tormysql

    pool = tormysql.ConnectionPool(
        max_connections = 20, #max open connections
        idle_seconds = 7200, #conntion idle timeout time, 0 is not timeout
        wait_connection_timeout = 3, #wait connection timeout
        host = "127.0.0.1",
        user = "root",
        passwd = "TEST",
        db = "test",
        charset = "utf8"
    )

    @gen.coroutine
    def test():
        with (yield pool.Connection()) as conn:
            try:
                with conn.cursor() as cursor:
                    yield cursor.execute("INSERT INTO test(id) VALUES(1)")
            except:
                yield conn.rollback()
            else:
                yield conn.commit()

            with conn.cursor() as cursor:
                yield cursor.execute("SELECT * FROM test")
                datas = cursor.fetchall()

        print datas
        
        yield pool.close()

    ioloop = IOLoop.instance()
    ioloop.run_sync(test)

example helpers
---------------

::

    from tornado.ioloop import IOLoop
    from tornado import gen
    import tormysql

    pool = tormysql.helpers.ConnectionPool(
        max_connections = 20, #max open connections
        idle_seconds = 7200, #conntion idle timeout time, 0 is not timeout
        wait_connection_timeout = 3, #wait connection timeout
        host = "127.0.0.1",
        user = "root",
        passwd = "TEST",
        db = "test",
        charset = "utf8"
    )

    @gen.coroutine
    def test():
        tx = yield pool.begin()
        try:
            yield tx.execute("INSERT INTO test(id) VALUES(1)")
        except:
            yield tx.rollback()
        else:
            yield tx.commit()

        cursor = yield pool.execute("SELECT * FROM test")
        datas = cursor.fetchall()

        print datas

        yield pool.close()

    ioloop = IOLoop.instance()
    ioloop.run_sync(test)

Used asyncio alone
==================

example pool
------------

::

    from asyncio import events
    import tormysql

    pool = tormysql.ConnectionPool(
       max_connections = 20, #max open connections
       idle_seconds = 7200, #conntion idle timeout time, 0 is not timeout
       wait_connection_timeout = 3, #wait connection timeout
       host = "127.0.0.1",
       user = "root",
       passwd = "TEST",
       db = "test",
       charset = "utf8"
    )

    async def test():
       async with await pool.Connection() as conn:
           try:
               async with conn.cursor() as cursor:
                   await cursor.execute("INSERT INTO test(id) VALUES(1)")
           except:
               await conn.rollback()
           else:
               await conn.commit()

           async with conn.cursor() as cursor:
               await cursor.execute("SELECT * FROM test")
               datas = cursor.fetchall()

       print(datas)

       await pool.close()

    ioloop = events.get_event_loop()
    ioloop.run_until_complete(test)

example helpers
---------------

::

    from asyncio import events
    import tormysql

    pool = tormysql.helpers.ConnectionPool(
       max_connections = 20, #max open connections
       idle_seconds = 7200, #conntion idle timeout time, 0 is not timeout
       wait_connection_timeout = 3, #wait connection timeout
       host = "127.0.0.1",
       user = "root",
       passwd = "TEST",
       db = "test",
       charset = "utf8"
    )

    async def test():
       async with await pool.begin() as tx:
           await tx.execute("INSERT INTO test(id) VALUES(1)")

       cursor = await pool.execute("SELECT * FROM test")
       datas = cursor.fetchall()

       print(datas)

       await pool.close()

    ioloop = events.get_event_loop()
    ioloop.run_until_complete(test)

Resources
=========

You can read `PyMySQL Documentation <http://pymysql.readthedocs.io/>`__
online for more information.

License
=======

TorMySQL uses the MIT license, see LICENSE file for the details.

.. |Build Status| image:: https://travis-ci.org/snower/TorMySQL.svg?branch=master
   :target: https://travis-ci.org/snower/TorMySQL
            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/snower/TorMySQL",
    "name": "tormysql",
    "maintainer": "",
    "docs_url": null,
    "requires_python": "",
    "maintainer_email": "",
    "keywords": "tornado,mysql",
    "author": "snower, mosquito",
    "author_email": "sujian199@gmail.com, me@mosquito.su",
    "download_url": "https://files.pythonhosted.org/packages/df/b5/e06e7f5321b118a05e42c88fb0fba91f698b907fa92eb24eb35e05bff2dc/tormysql-0.4.3.tar.gz",
    "platform": "",
    "description": "TorMySQL\n========\n\n|Build Status|\n\nThe highest performance asynchronous MySQL driver.\n\nPyPI page: https://pypi.python.org/pypi/tormysql\n\nAbout\n=====\n\nPresents a Future-based API and greenlet for non-blocking access to\nMySQL.\n\nSupport both `tornado <https://github.com/tornadoweb/tornado>`__ and\n`asyncio <https://docs.python.org/3/library/asyncio.html>`__.\n\nInstallation\n============\n\n::\n\n    pip install TorMySQL\n\nUsed Tornado\n============\n\nexample pool\n------------\n\n::\n\n    from tornado.ioloop import IOLoop\n    from tornado import gen\n    import tormysql\n\n    pool = 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\n    def 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\n    ioloop = IOLoop.instance()\n    ioloop.run_sync(test)\n\nexample helpers\n---------------\n\n::\n\n    from tornado.ioloop import IOLoop\n    from tornado import gen\n    import tormysql\n\n    pool = 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\n    def 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\n    ioloop = IOLoop.instance()\n    ioloop.run_sync(test)\n\nUsed asyncio alone\n==================\n\nexample pool\n------------\n\n::\n\n    from asyncio import events\n    import tormysql\n\n    pool = 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    async 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\n    ioloop = events.get_event_loop()\n    ioloop.run_until_complete(test)\n\nexample helpers\n---------------\n\n::\n\n    from asyncio import events\n    import tormysql\n\n    pool = 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    async 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\n    ioloop = events.get_event_loop()\n    ioloop.run_until_complete(test)\n\nResources\n=========\n\nYou can read `PyMySQL Documentation <http://pymysql.readthedocs.io/>`__\nonline for more information.\n\nLicense\n=======\n\nTorMySQL uses the MIT license, see LICENSE file for the details.\n\n.. |Build Status| image:: https://travis-ci.org/snower/TorMySQL.svg?branch=master\n   :target: https://travis-ci.org/snower/TorMySQL",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "Tornado asynchronous MySQL Driver",
    "version": "0.4.3",
    "project_urls": {
        "Homepage": "https://github.com/snower/TorMySQL"
    },
    "split_keywords": [
        "tornado",
        "mysql"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "dfb5e06e7f5321b118a05e42c88fb0fba91f698b907fa92eb24eb35e05bff2dc",
                "md5": "bc60daea965e1eff48f8d2666d0ed53d",
                "sha256": "061c7ce434967e3e0bf7e7b3e3032a479a2eac4cf623095db06f6ad64aa62b44"
            },
            "downloads": -1,
            "filename": "tormysql-0.4.3.tar.gz",
            "has_sig": false,
            "md5_digest": "bc60daea965e1eff48f8d2666d0ed53d",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": null,
            "size": 14978,
            "upload_time": "2021-01-11T11:00:28",
            "upload_time_iso_8601": "2021-01-11T11:00:28.399617Z",
            "url": "https://files.pythonhosted.org/packages/df/b5/e06e7f5321b118a05e42c88fb0fba91f698b907fa92eb24eb35e05bff2dc/tormysql-0.4.3.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2021-01-11 11:00:28",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "snower",
    "github_project": "TorMySQL",
    "travis_ci": true,
    "coveralls": false,
    "github_actions": false,
    "lcname": "tormysql"
}
        
Elapsed time: 3.73822s