All Projects → aio-libs → Aiomysql

aio-libs / Aiomysql

Licence: mit
aiomysql is a library for accessing a MySQL database from the asyncio

Programming Languages

python
139335 projects - #7 most used programming language

Projects that are alternatives of or similar to Aiomysql

Tormysql
The highest performance asynchronous MySQL driver by PyMySQL
Stars: ✭ 302 (-75.88%)
Mutual labels:  asyncio, mysql, mariadb
Databases
Async database support for Python. 🗄
Stars: ✭ 2,602 (+107.83%)
Mutual labels:  asyncio, sqlalchemy, mysql
Mariadb Container
MariaDB container images based on Red Hat Software Collections and intended for OpenShift and general usage. Users can choose between Red Hat Enterprise Linux, Fedora, and CentOS based images.
Stars: ✭ 19 (-98.48%)
Mutual labels:  mysql, mariadb
Jale
Jale is a blazing fast local development environment for MacOS written in Typescript.
Stars: ✭ 24 (-98.08%)
Mutual labels:  mysql, mariadb
Tbls
tbls is a CI-Friendly tool for document a database, written in Go.
Stars: ✭ 940 (-24.92%)
Mutual labels:  mysql, mariadb
Migrate
Database migrations. CLI and Golang library.
Stars: ✭ 7,712 (+515.97%)
Mutual labels:  mysql, mariadb
Eralchemy
Entity Relation Diagrams generation tool
Stars: ✭ 767 (-38.74%)
Mutual labels:  sqlalchemy, mysql
Skeema
Schema management CLI for MySQL
Stars: ✭ 859 (-31.39%)
Mutual labels:  mysql, mariadb
Phpmyadmin
A web interface for MySQL and MariaDB
Stars: ✭ 5,750 (+359.27%)
Mutual labels:  mysql, mariadb
Dbbench
🏋️ dbbench is a simple database benchmarking tool which supports several databases and own scripts
Stars: ✭ 52 (-95.85%)
Mutual labels:  mysql, mariadb
Mysqldump Php
PHP version of mysqldump cli that comes with MySQL
Stars: ✭ 975 (-22.12%)
Mutual labels:  mysql, mariadb
Web Applications With Fastapi Course
Demo code and other handouts for students of our FastAPI Web Apps course.
Stars: ✭ 56 (-95.53%)
Mutual labels:  asyncio, sqlalchemy
Mycat2
MySQL Proxy using Java NIO based on Sharding SQL,Calcite ,simple and fast
Stars: ✭ 750 (-40.1%)
Mutual labels:  mysql, mariadb
Sequelize
An easy-to-use and promise-based multi SQL dialects ORM tool for Node.js
Stars: ✭ 25,422 (+1930.51%)
Mutual labels:  mysql, mariadb
Ansible Role Mysql
Ansible Role - MySQL
Stars: ✭ 826 (-34.03%)
Mutual labels:  mysql, mariadb
Sqlancer
Detecting Logic Bugs in DBMS
Stars: ✭ 672 (-46.33%)
Mutual labels:  mysql, mariadb
Mysqlconnector
Async MySQL Connector for .NET and .NET Core
Stars: ✭ 942 (-24.76%)
Mutual labels:  mysql, mariadb
Ebean
Ebean ORM
Stars: ✭ 1,172 (-6.39%)
Mutual labels:  mysql, mariadb
Peewee Async
Asynchronous interface for peewee ORM powered by asyncio
Stars: ✭ 607 (-51.52%)
Mutual labels:  asyncio, mysql
Dbshield
Database firewall written in Go
Stars: ✭ 620 (-50.48%)
Mutual labels:  mysql, mariadb

aiomysql

.. image:: https://travis-ci.com/aio-libs/aiomysql.svg?branch=master :target: https://travis-ci.com/aio-libs/aiomysql .. image:: https://codecov.io/gh/aio-libs/aiomysql/branch/master/graph/badge.svg :target: https://codecov.io/gh/aio-libs/aiomysql :alt: Code coverage .. image:: https://badge.fury.io/py/aiomysql.svg :target: https://badge.fury.io/py/aiomysql :alt: Latest Version .. image:: https://readthedocs.org/projects/aiomysql/badge/?version=latest :target: https://aiomysql.readthedocs.io/ :alt: Documentation Status .. image:: https://badges.gitter.im/Join%20Chat.svg :target: https://gitter.im/aio-libs/Lobby :alt: Chat on Gitter

aiomysql is a "driver" for accessing a MySQL database from the asyncio_ (PEP-3156/tulip) framework. It depends on and reuses most parts of PyMySQL_ . aiomysql tries to be like awesome aiopg_ library and preserve same api, look and feel.

Internally aiomysql is copy of PyMySQL, underlying io calls switched to async, basically yield from and asyncio.coroutine added in proper places)). sqlalchemy support ported from aiopg_.

Documentation

https://aiomysql.readthedocs.io/

Mailing List

https://groups.google.com/forum/#!forum/aio-libs

Basic Example

aiomysql based on PyMySQL_ , and provides same api, you just need to use await conn.f() or yield from conn.f() instead of calling conn.f() for every method.

Properties are unchanged, so conn.prop is correct as well as conn.prop = val.

.. code:: python

import asyncio
import aiomysql


async def test_example(loop):
    pool = await aiomysql.create_pool(host='127.0.0.1', port=3306,
                                      user='root', password='',
                                      db='mysql', loop=loop)
    async with pool.acquire() as conn:
        async with conn.cursor() as cur:
            await cur.execute("SELECT 42;")
            print(cur.description)
            (r,) = await cur.fetchone()
            assert r == 42
    pool.close()
    await pool.wait_closed()


loop = asyncio.get_event_loop()
loop.run_until_complete(test_example(loop))

Example of SQLAlchemy optional integration

Sqlalchemy support has been ported from aiopg_ so api should be very familiar for aiopg_ user.:

.. code:: python

import asyncio
import sqlalchemy as sa

from aiomysql.sa import create_engine


metadata = sa.MetaData()

tbl = sa.Table('tbl', metadata,
               sa.Column('id', sa.Integer, primary_key=True),
               sa.Column('val', sa.String(255)))


async def go(loop):
    engine = await create_engine(user='root', db='test_pymysql',
                                 host='127.0.0.1', password='', loop=loop)
    async with engine.acquire() as conn:
        await conn.execute(tbl.insert().values(val='abc'))
        await conn.execute(tbl.insert().values(val='xyz'))

        async for row in conn.execute(tbl.select()):
            print(row.id, row.val)

    engine.close()
    await engine.wait_closed()


loop = asyncio.get_event_loop()
loop.run_until_complete(go(loop))

Requirements

  • Python_ 3.5.3+
  • PyMySQL_

.. _Python: https://www.python.org .. _asyncio: http://docs.python.org/3.5/library/asyncio.html .. _aiopg: https://github.com/aio-libs/aiopg .. _PyMySQL: https://github.com/PyMySQL/PyMySQL .. _Tornado-MySQL: https://github.com/PyMySQL/Tornado-MySQL

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].