METADATA 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180
  1. Metadata-Version: 2.1
  2. Name: PyMySQL
  3. Version: 1.0.2
  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 :: 3
  16. Classifier: Programming Language :: Python :: 3.6
  17. Classifier: Programming Language :: Python :: 3.7
  18. Classifier: Programming Language :: Python :: 3.8
  19. Classifier: Programming Language :: Python :: 3.9
  20. Classifier: Programming Language :: Python :: Implementation :: CPython
  21. Classifier: Programming Language :: Python :: Implementation :: PyPy
  22. Classifier: Intended Audience :: Developers
  23. Classifier: License :: OSI Approved :: MIT License
  24. Classifier: Topic :: Database
  25. Requires-Python: >=3.6
  26. Provides-Extra: ed25519
  27. Requires-Dist: PyNaCl (>=1.4.0) ; extra == 'ed25519'
  28. Provides-Extra: rsa
  29. Requires-Dist: cryptography ; extra == 'rsa'
  30. .. image:: https://readthedocs.org/projects/pymysql/badge/?version=latest
  31. :target: https://pymysql.readthedocs.io/
  32. :alt: Documentation Status
  33. .. image:: https://coveralls.io/repos/PyMySQL/PyMySQL/badge.svg?branch=master&service=github
  34. :target: https://coveralls.io/github/PyMySQL/PyMySQL?branch=master
  35. .. image:: https://img.shields.io/lgtm/grade/python/g/PyMySQL/PyMySQL.svg?logo=lgtm&logoWidth=18
  36. :target: https://lgtm.com/projects/g/PyMySQL/PyMySQL/context:python
  37. PyMySQL
  38. =======
  39. .. contents:: Table of Contents
  40. :local:
  41. This package contains a pure-Python MySQL client library, based on `PEP 249`_.
  42. Most public APIs are compatible with mysqlclient and MySQLdb.
  43. NOTE: PyMySQL doesn't support low level APIs `_mysql` provides like `data_seek`,
  44. `store_result`, and `use_result`. You should use high level APIs defined in `PEP 249`_.
  45. But some APIs like `autocommit` and `ping` are supported because `PEP 249`_ doesn't cover
  46. their usecase.
  47. .. _`PEP 249`: https://www.python.org/dev/peps/pep-0249/
  48. Requirements
  49. -------------
  50. * Python -- one of the following:
  51. - CPython_ : 3.6 and newer
  52. - PyPy_ : Latest 3.x version
  53. * MySQL Server -- one of the following:
  54. - MySQL_ >= 5.6
  55. - MariaDB_ >= 10.0
  56. .. _CPython: https://www.python.org/
  57. .. _PyPy: https://pypy.org/
  58. .. _MySQL: https://www.mysql.com/
  59. .. _MariaDB: https://mariadb.org/
  60. Installation
  61. ------------
  62. Package is uploaded on `PyPI <https://pypi.org/project/PyMySQL>`_.
  63. You can install it with pip::
  64. $ python3 -m pip install PyMySQL
  65. To use "sha256_password" or "caching_sha2_password" for authenticate,
  66. you need to install additional dependency::
  67. $ python3 -m pip install PyMySQL[rsa]
  68. To use MariaDB's "ed25519" authentication method, you need to install
  69. additional dependency::
  70. $ python3 -m pip install PyMySQL[ed25519]
  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=utf8mb4 COLLATE=utf8mb4_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. database='db',
  94. cursorclass=pymysql.cursors.DictCursor)
  95. with connection:
  96. with connection.cursor() as cursor:
  97. # Create a new record
  98. sql = "INSERT INTO `users` (`email`, `password`) VALUES (%s, %s)"
  99. cursor.execute(sql, ('webmaster@python.org', 'very-secret'))
  100. # connection is not autocommit by default. So you must commit to save
  101. # your changes.
  102. connection.commit()
  103. with connection.cursor() as cursor:
  104. # Read a single record
  105. sql = "SELECT `id`, `password` FROM `users` WHERE `email`=%s"
  106. cursor.execute(sql, ('webmaster@python.org',))
  107. result = cursor.fetchone()
  108. print(result)
  109. This example will print:
  110. .. code:: python
  111. {'password': 'very-secret', 'id': 1}
  112. Resources
  113. ---------
  114. * DB-API 2.0: https://www.python.org/dev/peps/pep-0249/
  115. * MySQL Reference Manuals: https://dev.mysql.com/doc/
  116. * MySQL client/server protocol:
  117. https://dev.mysql.com/doc/internals/en/client-server-protocol.html
  118. * "Connector" channel in MySQL Community Slack:
  119. https://lefred.be/mysql-community-on-slack/
  120. * PyMySQL mailing list: https://groups.google.com/forum/#!forum/pymysql-users
  121. License
  122. -------
  123. PyMySQL is released under the MIT License. See LICENSE for more information.