PageRenderTime 48ms CodeModel.GetById 20ms RepoModel.GetById 0ms app.codeStats 0ms

/docs/index.rst

https://gitlab.com/carmes/aiomysql
ReStructuredText | 141 lines | 97 code | 44 blank | 0 comment | 0 complexity | 4054644f8ec0366db3c33c1ff3546d46 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.4/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 ``yield from`` and ``asyncio.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 ``yield from 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. @asyncio.coroutine
  39. def test_example():
  40. conn = yield from aiomysql.connect(host='127.0.0.1', port=3306,
  41. user='root', password='', db='mysql',
  42. loop=loop)
  43. cur = yield from conn.cursor()
  44. yield from cur.execute("SELECT Host,User FROM user")
  45. print(cur.description)
  46. r = yield from cur.fetchall()
  47. print(r)
  48. yield from cur.close()
  49. conn.close()
  50. loop.run_until_complete(test_example())
  51. Installation
  52. ------------
  53. .. code::
  54. pip3 install aiomysql
  55. .. note:: :mod:`aiomysql` requires :term:`PyMySQL` library.
  56. Also you probably want to use :mod:`aiomysql.sa`.
  57. .. _aiomysql-install-sqlalchemy:
  58. :mod:`aiomysql.sa` module is **optional** and requires
  59. :term:`sqlalchemy`. You can install *sqlalchemy* by running::
  60. pip3 install sqlalchemy
  61. Source code
  62. -----------
  63. The project is hosted on GitHub_
  64. Please feel free to file an issue on `bug tracker
  65. <https://github.com/aio-libs/aiomysql/issues>`_ if you have found a bug
  66. or have some suggestion for library improvement.
  67. The library uses `Travis <https://travis-ci.org/aio-libs/aiomysql>`_ for
  68. Continious Integration and `Coveralls
  69. <https://coveralls.io/r/aio-libs/aiomysql?branch=master>`_ for
  70. coverage reports.
  71. Dependencies
  72. ------------
  73. - Python 3.3 and :mod:`asyncio` or Python 3.4+
  74. - :term:`PyMySQL`
  75. - aiomysql.sa requires :term:`sqlalchemy`.
  76. Authors and License
  77. -------------------
  78. The ``aiomysql`` package is written by Nikolay Novik, :term:`PyMySQL` and
  79. aio-libs_ contributors. It's MIT licensed (same as PyMySQL).
  80. Feel free to improve this package and send a pull request to GitHub_.
  81. Contents:
  82. ---------
  83. .. toctree::
  84. :maxdepth: 2
  85. connection
  86. cursors
  87. pool
  88. tutorial
  89. sa
  90. examples
  91. glossary
  92. contributing
  93. Indices and tables
  94. ==================
  95. * :ref:`genindex`
  96. * :ref:`modindex`
  97. * :ref:`search`