{"id":13482047,"url":"https://github.com/aio-libs/aiomysql","last_synced_at":"2025-05-12T11:18:12.953Z","repository":{"id":25500690,"uuid":"28932001","full_name":"aio-libs/aiomysql","owner":"aio-libs","description":"aiomysql is a library for accessing a MySQL database from the asyncio","archived":false,"fork":false,"pushed_at":"2024-12-23T16:25:23.000Z","size":1390,"stargazers_count":1811,"open_issues_count":117,"forks_count":260,"subscribers_count":44,"default_branch":"master","last_synced_at":"2025-05-11T11:11:17.649Z","etag":null,"topics":["aiomysql","async","asyncio","mariadb","mysql","python","sqlalchemy"],"latest_commit_sha":null,"homepage":"https://aiomysql.rtfd.io","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/aio-libs.png","metadata":{"files":{"readme":"README.rst","changelog":"CHANGES.txt","contributing":"CONTRIBUTING.rst","funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2015-01-07T20:14:48.000Z","updated_at":"2025-05-09T06:25:40.000Z","dependencies_parsed_at":"2024-01-09T09:07:32.207Z","dependency_job_id":"bb2a1917-91d0-4372-a4ff-4c7af496427c","html_url":"https://github.com/aio-libs/aiomysql","commit_stats":{"total_commits":1110,"total_committers":104,"mean_commits":"10.673076923076923","dds":0.7441441441441441,"last_synced_commit":"83aa96e12b1b3f2bd373f60a9c585b6e73f40f52"},"previous_names":[],"tags_count":26,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aio-libs%2Faiomysql","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aio-libs%2Faiomysql/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aio-libs%2Faiomysql/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aio-libs%2Faiomysql/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/aio-libs","download_url":"https://codeload.github.com/aio-libs/aiomysql/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":253554090,"owners_count":21926614,"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":["aiomysql","async","asyncio","mariadb","mysql","python","sqlalchemy"],"created_at":"2024-07-31T17:00:58.487Z","updated_at":"2025-05-11T11:11:24.950Z","avatar_url":"https://github.com/aio-libs.png","language":"Python","funding_links":[],"categories":["Python","资源列表","Database Drivers","数据库驱动"],"sub_categories":["数据库驱动"],"readme":"aiomysql\n========\n.. image:: https://github.com/aio-libs/aiomysql/actions/workflows/ci-cd.yml/badge.svg?branch=master\n    :target: https://github.com/aio-libs/aiomysql/actions/workflows/ci-cd.yml\n.. image:: https://codecov.io/gh/aio-libs/aiomysql/branch/master/graph/badge.svg\n    :target: https://codecov.io/gh/aio-libs/aiomysql\n    :alt: Code coverage\n.. image:: https://badge.fury.io/py/aiomysql.svg\n    :target: https://badge.fury.io/py/aiomysql\n    :alt: Latest Version\n.. image:: https://readthedocs.org/projects/aiomysql/badge/?version=latest\n    :target: https://aiomysql.readthedocs.io/\n    :alt: Documentation Status\n.. image:: https://badges.gitter.im/Join%20Chat.svg\n    :target: https://gitter.im/aio-libs/Lobby\n    :alt: Chat on Gitter\n\n**aiomysql** is a \"driver\" for accessing a `MySQL` database\nfrom the asyncio_ (PEP-3156/tulip) framework. It depends on and reuses most\nparts of PyMySQL_ . *aiomysql* tries to be like awesome aiopg_ library and\npreserve same api, look and feel.\n\nInternally **aiomysql** is copy of PyMySQL, underlying io calls switched\nto async, basically ``yield from`` and ``asyncio.coroutine`` added in\nproper places)). `sqlalchemy` support ported from aiopg_.\n\n\nDocumentation\n-------------\nhttps://aiomysql.readthedocs.io/\n\nBasic Example\n-------------\n\n**aiomysql** based on PyMySQL_ , and provides same api, you just need\nto use  ``await conn.f()`` or ``yield from conn.f()`` instead of calling\n``conn.f()`` for every method.\n\nProperties are unchanged, so ``conn.prop`` is correct as well as\n``conn.prop = val``.\n\n.. code:: python\n\n    import asyncio\n    import aiomysql\n\n\n    async def test_example(loop):\n        pool = await aiomysql.create_pool(host='127.0.0.1', port=3306,\n                                          user='root', password='',\n                                          db='mysql', loop=loop)\n        async with pool.acquire() as conn:\n            async with conn.cursor() as cur:\n                await cur.execute(\"SELECT 42;\")\n                print(cur.description)\n                (r,) = await cur.fetchone()\n                assert r == 42\n        pool.close()\n        await pool.wait_closed()\n\n\n    loop = asyncio.get_event_loop()\n    loop.run_until_complete(test_example(loop))\n\n\nExample of SQLAlchemy optional integration\n------------------------------------------\nSqlalchemy support has been ported from aiopg_ so api should be very familiar\nfor aiopg_ user.:\n\n.. code:: python\n\n    import asyncio\n    import sqlalchemy as sa\n\n    from aiomysql.sa import create_engine\n\n\n    metadata = sa.MetaData()\n\n    tbl = sa.Table('tbl', metadata,\n                   sa.Column('id', sa.Integer, primary_key=True),\n                   sa.Column('val', sa.String(255)))\n\n\n    async def go(loop):\n        engine = await create_engine(user='root', db='test_pymysql',\n                                     host='127.0.0.1', password='', loop=loop)\n        async with engine.acquire() as conn:\n            await conn.execute(tbl.insert().values(val='abc'))\n            await conn.execute(tbl.insert().values(val='xyz'))\n\n            async for row in conn.execute(tbl.select()):\n                print(row.id, row.val)\n\n        engine.close()\n        await engine.wait_closed()\n\n\n    loop = asyncio.get_event_loop()\n    loop.run_until_complete(go(loop))\n\n\nRequirements\n------------\n\n* Python_ 3.7+\n* PyMySQL_\n\n\n.. _Python: https://www.python.org\n.. _asyncio: http://docs.python.org/3.5/library/asyncio.html\n.. _aiopg: https://github.com/aio-libs/aiopg\n.. _PyMySQL: https://github.com/PyMySQL/PyMySQL\n.. _Tornado-MySQL: https://github.com/PyMySQL/Tornado-MySQL\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Faio-libs%2Faiomysql","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Faio-libs%2Faiomysql","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Faio-libs%2Faiomysql/lists"}