/docs/index.rst

https://github.com/aio-libs/aiomysql · ReStructuredText · 141 lines · 96 code · 45 blank · 0 comment · 0 complexity · 5b7c792d59cf7114e47ee4071e10b26e MD5 · raw file

  1. .. aiomysql documentation master file, created by
  2. sphinx-quickstart on Sun Jan 18 22:02:31 2015.
  3. You can adapt this file completely to your liking, but it should at least
  4. contain the root `toctree` directive.
  5. Welcome to aiomysql's documentation!
  6. ====================================
  7. .. _GitHub: https://github.com/aio-libs/aiomysql
  8. .. _asyncio: http://docs.python.org/3.5/library/asyncio.html
  9. .. _aiopg: https://github.com/aio-libs/aiopg
  10. .. _Tornado-MySQL: https://github.com/PyMySQL/Tornado-MySQL
  11. .. _aio-libs: https://github.com/aio-libs
  12. **aiomysql** is a library for accessing a :term:`MySQL` database
  13. from the asyncio_ (PEP-3156/tulip) framework. It depends and reuses most parts
  14. of :term:`PyMySQL` . **aiomysql** tries to be like awesome aiopg_ library and preserve
  15. same api, look and feel.
  16. Internally **aiomysql** is copy of PyMySQL, underlying io calls switched
  17. to async, basically ``await`` and ``async def coroutine`` added in
  18. proper places. :term:`sqlalchemy` support ported from aiopg_.
  19. Features
  20. --------
  21. * Implements *asyncio* :term:`DBAPI` *like* interface for
  22. :term:`MySQL`. It includes :ref:`aiomysql-connection`,
  23. :ref:`aiomysql-cursors` and :ref:`aiomysql-pool` objects.
  24. * Implements *optional* support for charming :term:`sqlalchemy`
  25. functional sql layer.
  26. Basics
  27. ------
  28. **aiomysql** based on :term:`PyMySQL` , and provides same api, you just need
  29. to use ``await conn.f()`` instead of just call ``conn.f()`` for
  30. every method.
  31. Properties are unchanged, so ``conn.prop`` is correct as well as
  32. ``conn.prop = val``.
  33. See example:
  34. .. code:: python
  35. import asyncio
  36. import aiomysql
  37. loop = asyncio.get_event_loop()
  38. async def test_example():
  39. conn = await aiomysql.connect(host='127.0.0.1', port=3306,
  40. user='root', password='', db='mysql',
  41. loop=loop)
  42. cur = await conn.cursor()
  43. await cur.execute("SELECT Host,User FROM user")
  44. print(cur.description)
  45. r = await cur.fetchall()
  46. print(r)
  47. await cur.close()
  48. conn.close()
  49. loop.run_until_complete(test_example())
  50. Installation
  51. ------------
  52. .. code::
  53. pip3 install aiomysql
  54. .. note:: :mod:`aiomysql` requires :term:`PyMySQL` library.
  55. Also you probably want to use :mod:`aiomysql.sa`.
  56. .. _aiomysql-install-sqlalchemy:
  57. :mod:`aiomysql.sa` module is **optional** and requires
  58. :term:`sqlalchemy`. You can install *sqlalchemy* by running::
  59. pip3 install sqlalchemy
  60. Source code
  61. -----------
  62. The project is hosted on GitHub_
  63. Please feel free to file an issue on `bug tracker
  64. <https://github.com/aio-libs/aiomysql/issues>`_ if you have found a bug
  65. or have some suggestion for library improvement.
  66. The library uses `Travis <https://travis-ci.org/aio-libs/aiomysql>`_ for
  67. Continious Integration and `Coveralls
  68. <https://coveralls.io/r/aio-libs/aiomysql?branch=master>`_ for
  69. coverage reports.
  70. Dependencies
  71. ------------
  72. - Python 3.5.3+
  73. - :term:`PyMySQL`
  74. - aiomysql.sa requires :term:`sqlalchemy`.
  75. Authors and License
  76. -------------------
  77. The ``aiomysql`` package is written by Nikolay Novik, :term:`PyMySQL` and
  78. aio-libs_ contributors. It's MIT licensed (same as PyMySQL).
  79. Feel free to improve this package and send a pull request to GitHub_.
  80. Contents:
  81. ---------
  82. .. toctree::
  83. :maxdepth: 2
  84. connection
  85. cursors
  86. pool
  87. tutorial
  88. sa
  89. examples
  90. glossary
  91. contributing
  92. Indices and tables
  93. ==================
  94. * :ref:`genindex`
  95. * :ref:`modindex`
  96. * :ref:`search`