METADATA 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134
  1. Metadata-Version: 2.1
  2. Name: PyMySQL
  3. Version: 1.1.0
  4. Summary: Pure Python MySQL Driver
  5. Author-email: Inada Naoki <songofacandy@gmail.com>, Yutaka Matsubara <yutaka.matsubara@gmail.com>
  6. License: MIT License
  7. Project-URL: Project, https://github.com/PyMySQL/PyMySQL
  8. Project-URL: Documentation, https://pymysql.readthedocs.io/
  9. Keywords: MySQL
  10. Classifier: Development Status :: 5 - Production/Stable
  11. Classifier: Programming Language :: Python :: 3
  12. Classifier: Programming Language :: Python :: 3.7
  13. Classifier: Programming Language :: Python :: 3.8
  14. Classifier: Programming Language :: Python :: 3.9
  15. Classifier: Programming Language :: Python :: 3.10
  16. Classifier: Programming Language :: Python :: 3.11
  17. Classifier: Programming Language :: Python :: Implementation :: CPython
  18. Classifier: Programming Language :: Python :: Implementation :: PyPy
  19. Classifier: Intended Audience :: Developers
  20. Classifier: License :: OSI Approved :: MIT License
  21. Classifier: Topic :: Database
  22. Requires-Python: >=3.7
  23. Description-Content-Type: text/markdown
  24. License-File: LICENSE
  25. Provides-Extra: ed25519
  26. Requires-Dist: PyNaCl (>=1.4.0) ; extra == 'ed25519'
  27. Provides-Extra: rsa
  28. Requires-Dist: cryptography ; extra == 'rsa'
  29. [![Documentation Status](https://readthedocs.org/projects/pymysql/badge/?version=latest)](https://pymysql.readthedocs.io/)
  30. [![codecov](https://codecov.io/gh/PyMySQL/PyMySQL/branch/main/graph/badge.svg?token=ppEuaNXBW4)](https://codecov.io/gh/PyMySQL/PyMySQL)
  31. # PyMySQL
  32. This package contains a pure-Python MySQL client library, based on [PEP
  33. 249](https://www.python.org/dev/peps/pep-0249/).
  34. ## Requirements
  35. - Python -- one of the following:
  36. - [CPython](https://www.python.org/) : 3.7 and newer
  37. - [PyPy](https://pypy.org/) : Latest 3.x version
  38. - MySQL Server -- one of the following:
  39. - [MySQL](https://www.mysql.com/) \>= 5.7
  40. - [MariaDB](https://mariadb.org/) \>= 10.4
  41. ## Installation
  42. Package is uploaded on [PyPI](https://pypi.org/project/PyMySQL).
  43. You can install it with pip:
  44. $ python3 -m pip install PyMySQL
  45. To use "sha256_password" or "caching_sha2_password" for authenticate,
  46. you need to install additional dependency:
  47. $ python3 -m pip install PyMySQL[rsa]
  48. To use MariaDB's "ed25519" authentication method, you need to install
  49. additional dependency:
  50. $ python3 -m pip install PyMySQL[ed25519]
  51. ## Documentation
  52. Documentation is available online: <https://pymysql.readthedocs.io/>
  53. For support, please refer to the
  54. [StackOverflow](https://stackoverflow.com/questions/tagged/pymysql).
  55. ## Example
  56. The following examples make use of a simple table
  57. ``` sql
  58. CREATE TABLE `users` (
  59. `id` int(11) NOT NULL AUTO_INCREMENT,
  60. `email` varchar(255) COLLATE utf8_bin NOT NULL,
  61. `password` varchar(255) COLLATE utf8_bin NOT NULL,
  62. PRIMARY KEY (`id`)
  63. ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin
  64. AUTO_INCREMENT=1 ;
  65. ```
  66. ``` python
  67. import pymysql.cursors
  68. # Connect to the database
  69. connection = pymysql.connect(host='localhost',
  70. user='user',
  71. password='passwd',
  72. database='db',
  73. cursorclass=pymysql.cursors.DictCursor)
  74. with connection:
  75. with connection.cursor() as cursor:
  76. # Create a new record
  77. sql = "INSERT INTO `users` (`email`, `password`) VALUES (%s, %s)"
  78. cursor.execute(sql, ('webmaster@python.org', 'very-secret'))
  79. # connection is not autocommit by default. So you must commit to save
  80. # your changes.
  81. connection.commit()
  82. with connection.cursor() as cursor:
  83. # Read a single record
  84. sql = "SELECT `id`, `password` FROM `users` WHERE `email`=%s"
  85. cursor.execute(sql, ('webmaster@python.org',))
  86. result = cursor.fetchone()
  87. print(result)
  88. ```
  89. This example will print:
  90. ``` python
  91. {'password': 'very-secret', 'id': 1}
  92. ```
  93. ## Resources
  94. - DB-API 2.0: <https://www.python.org/dev/peps/pep-0249/>
  95. - MySQL Reference Manuals: <https://dev.mysql.com/doc/>
  96. - MySQL client/server protocol:
  97. <https://dev.mysql.com/doc/internals/en/client-server-protocol.html>
  98. - "Connector" channel in MySQL Community Slack:
  99. <https://lefred.be/mysql-community-on-slack/>
  100. - PyMySQL mailing list:
  101. <https://groups.google.com/forum/#!forum/pymysql-users>
  102. ## License
  103. PyMySQL is released under the MIT License. See LICENSE for more
  104. information.