Fix bug base on Pure Python MySQL Driver and Inception
Project description
PyMySQL
This package contains a pure-Python MySQL client library, based on PEP 249.
Requirements
Installation
Package is uploaded on PyPI.
You can install it with pip:
$ python3 -m pip install PyMySQL
To use “sha256_password” or “caching_sha2_password” for authenticate, you need to install additional dependency:
$ python3 -m pip install PyMySQL[rsa]
To use MariaDB’s “ed25519” authentication method, you need to install additional dependency:
$ python3 -m pip install PyMySQL[ed25519]
Documentation
Documentation is available online: https://pymysql.readthedocs.io/
For support, please refer to the StackOverflow.
Example
The following examples make use of a simple table
CREATE TABLE `users` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`email` varchar(255) COLLATE utf8_bin NOT NULL,
`password` varchar(255) COLLATE utf8_bin NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin
AUTO_INCREMENT=1 ;
import pymysql.cursors
# Connect to the database
connection = pymysql.connect(host='localhost',
user='user',
password='passwd',
database='db',
cursorclass=pymysql.cursors.DictCursor)
with connection:
with connection.cursor() as cursor:
# Create a new record
sql = "INSERT INTO `users` (`email`, `password`) VALUES (%s, %s)"
cursor.execute(sql, ('webmaster@python.org', 'very-secret'))
# connection is not autocommit by default. So you must commit to save
# your changes.
connection.commit()
with connection.cursor() as cursor:
# Read a single record
sql = "SELECT `id`, `password` FROM `users` WHERE `email`=%s"
cursor.execute(sql, ('webmaster@python.org',))
result = cursor.fetchone()
print(result)
This example will print:
{'password': 'very-secret', 'id': 1}
Resources
DB-API 2.0: https://www.python.org/dev/peps/pep-0249/
MySQL Reference Manuals: https://dev.mysql.com/doc/
MySQL client/server protocol: https://dev.mysql.com/doc/internals/en/client-server-protocol.html
“Connector” channel in MySQL Community Slack: https://lefred.be/mysql-community-on-slack/
PyMySQL mailing list: https://groups.google.com/forum/#!forum/pymysql-users
License
PyMySQL is released under the MIT License. See LICENSE for more information.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file PyMySQLPlus-1.0.2.tar.gz
.
File metadata
- Download URL: PyMySQLPlus-1.0.2.tar.gz
- Upload date:
- Size: 43.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.3.0 pkginfo/1.7.0 requests/2.25.1 setuptools/52.0.0 requests-toolbelt/0.9.1 tqdm/4.57.0 CPython/3.7.9
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 5b4cdd330675cf7e8f2a77514945438df2d4017cb18dd3cbde513622f40472e6 |
|
MD5 | 4a12f2792b55f675f3e0552f4001b85c |
|
BLAKE2b-256 | fe49900a1ce565fb46c2c5a1a887593872c696e5628fd50c1e5d4e0501726886 |
File details
Details for the file PyMySQLPlus-1.0.2-py3-none-any.whl
.
File metadata
- Download URL: PyMySQLPlus-1.0.2-py3-none-any.whl
- Upload date:
- Size: 43.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.3.0 pkginfo/1.7.0 requests/2.25.1 setuptools/52.0.0 requests-toolbelt/0.9.1 tqdm/4.57.0 CPython/3.7.9
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 98efab99f6748b03b640263be81804edaab4cd56ff7a038265d79d94fd40115b |
|
MD5 | c03e84e88a0f9c8c0c3d24f7649a51e9 |
|
BLAKE2b-256 | b3621a1e26cdaa5492a64050a8cf89ea58edf516714c140b5e898d013abd3804 |