METADATA 4.3 KB

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