METADATA 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181
  1. Metadata-Version: 2.1
  2. Name: PyMySQL
  3. Version: 0.9.3
  4. Summary: Pure Python MySQL Driver
  5. Home-page: https://github.com/PyMySQL/PyMySQL/
  6. Author: yutaka.matsubara
  7. Author-email: yutaka.matsubara@gmail.com
  8. Maintainer: INADA Naoki
  9. Maintainer-email: songofacandy@gmail.com
  10. License: "MIT"
  11. Project-URL: Documentation, https://pymysql.readthedocs.io/
  12. Keywords: MySQL
  13. Platform: UNKNOWN
  14. Classifier: Development Status :: 5 - Production/Stable
  15. Classifier: Programming Language :: Python :: 2
  16. Classifier: Programming Language :: Python :: 2.7
  17. Classifier: Programming Language :: Python :: 3
  18. Classifier: Programming Language :: Python :: 3.4
  19. Classifier: Programming Language :: Python :: 3.5
  20. Classifier: Programming Language :: Python :: 3.6
  21. Classifier: Programming Language :: Python :: 3.7
  22. Classifier: Programming Language :: Python :: Implementation :: CPython
  23. Classifier: Programming Language :: Python :: Implementation :: PyPy
  24. Classifier: Intended Audience :: Developers
  25. Classifier: License :: OSI Approved :: MIT License
  26. Classifier: Topic :: Database
  27. Provides-Extra: rsa
  28. Requires-Dist: cryptography ; extra == 'rsa'
  29. .. image:: https://readthedocs.org/projects/pymysql/badge/?version=latest
  30. :target: https://pymysql.readthedocs.io/
  31. :alt: Documentation Status
  32. .. image:: https://badge.fury.io/py/PyMySQL.svg
  33. :target: https://badge.fury.io/py/PyMySQL
  34. .. image:: https://travis-ci.org/PyMySQL/PyMySQL.svg?branch=master
  35. :target: https://travis-ci.org/PyMySQL/PyMySQL
  36. .. image:: https://coveralls.io/repos/PyMySQL/PyMySQL/badge.svg?branch=master&service=github
  37. :target: https://coveralls.io/github/PyMySQL/PyMySQL?branch=master
  38. .. image:: https://img.shields.io/badge/license-MIT-blue.svg
  39. :target: https://github.com/PyMySQL/PyMySQL/blob/master/LICENSE
  40. PyMySQL
  41. =======
  42. .. contents:: Table of Contents
  43. :local:
  44. This package contains a pure-Python MySQL client library, based on `PEP 249`_.
  45. Most public APIs are compatible with mysqlclient and MySQLdb.
  46. NOTE: PyMySQL doesn't support low level APIs `_mysql` provides like `data_seek`,
  47. `store_result`, and `use_result`. You should use high level APIs defined in `PEP 249`_.
  48. But some APIs like `autocommit` and `ping` are supported because `PEP 249`_ doesn't cover
  49. their usecase.
  50. .. _`PEP 249`: https://www.python.org/dev/peps/pep-0249/
  51. Requirements
  52. -------------
  53. * Python -- one of the following:
  54. - CPython_ : 2.7 and >= 3.4
  55. - PyPy_ : Latest version
  56. * MySQL Server -- one of the following:
  57. - MySQL_ >= 5.5
  58. - MariaDB_ >= 5.5
  59. .. _CPython: https://www.python.org/
  60. .. _PyPy: https://pypy.org/
  61. .. _MySQL: https://www.mysql.com/
  62. .. _MariaDB: https://mariadb.org/
  63. Installation
  64. ------------
  65. Package is uploaded on `PyPI <https://pypi.org/project/PyMySQL>`_.
  66. You can install it with pip::
  67. $ python3 -m pip install PyMySQL
  68. To use "sha256_password" or "caching_sha2_password" for authenticate,
  69. you need to install additional dependency::
  70. $ python3 -m pip install PyMySQL[rsa]
  71. Documentation
  72. -------------
  73. Documentation is available online: https://pymysql.readthedocs.io/
  74. For support, please refer to the `StackOverflow
  75. <https://stackoverflow.com/questions/tagged/pymysql>`_.
  76. Example
  77. -------
  78. The following examples make use of a simple table
  79. .. code:: sql
  80. CREATE TABLE `users` (
  81. `id` int(11) NOT NULL AUTO_INCREMENT,
  82. `email` varchar(255) COLLATE utf8_bin NOT NULL,
  83. `password` varchar(255) COLLATE utf8_bin NOT NULL,
  84. PRIMARY KEY (`id`)
  85. ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin
  86. AUTO_INCREMENT=1 ;
  87. .. code:: python
  88. import pymysql.cursors
  89. # Connect to the database
  90. connection = pymysql.connect(host='localhost',
  91. user='user',
  92. password='passwd',
  93. db='db',
  94. charset='utf8mb4',
  95. cursorclass=pymysql.cursors.DictCursor)
  96. try:
  97. with connection.cursor() as cursor:
  98. # Create a new record
  99. sql = "INSERT INTO `users` (`email`, `password`) VALUES (%s, %s)"
  100. cursor.execute(sql, ('webmaster@python.org', 'very-secret'))
  101. # connection is not autocommit by default. So you must commit to save
  102. # your changes.
  103. connection.commit()
  104. with connection.cursor() as cursor:
  105. # Read a single record
  106. sql = "SELECT `id`, `password` FROM `users` WHERE `email`=%s"
  107. cursor.execute(sql, ('webmaster@python.org',))
  108. result = cursor.fetchone()
  109. print(result)
  110. finally:
  111. connection.close()
  112. This example will print:
  113. .. code:: python
  114. {'password': 'very-secret', 'id': 1}
  115. Resources
  116. ---------
  117. * DB-API 2.0: https://www.python.org/dev/peps/pep-0249/
  118. * MySQL Reference Manuals: https://dev.mysql.com/doc/
  119. * MySQL client/server protocol:
  120. https://dev.mysql.com/doc/internals/en/client-server-protocol.html
  121. * "Connector" channel in MySQL Community Slack:
  122. https://lefred.be/mysql-community-on-slack/
  123. * PyMySQL mailing list: https://groups.google.com/forum/#!forum/pymysql-users
  124. License
  125. -------
  126. PyMySQL is released under the MIT License. See LICENSE for more information.