Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/main' into fix-sscursor-raisin…
Browse files Browse the repository at this point in the history
…g-error-from-previous-query
  • Loading branch information
methane committed May 23, 2023
2 parents 852eb5c + 1448310 commit a5e84c1
Show file tree
Hide file tree
Showing 27 changed files with 220 additions and 249 deletions.
4 changes: 4 additions & 0 deletions .flake8
@@ -0,0 +1,4 @@
[flake8]
exclude = tests,build,.venv,docs
ignore = E203,W503,E722
max_line_length=129
4 changes: 2 additions & 2 deletions .github/FUNDING.yml
@@ -1,10 +1,10 @@
# These are supported funding model platforms

github: [methane] # Replace with up to 4 GitHub Sponsors-enabled usernames e.g., [user1, user2]
github: ["methane"] # Replace with up to 4 GitHub Sponsors-enabled usernames e.g., [user1, user2]
patreon: # Replace with a single Patreon username
open_collective: # Replace with a single Open Collective username
ko_fi: # Replace with a single Ko-fi username
tidelift: # Replace with a single Tidelift platform-name/package-name e.g., npm/babel
tidelift: "pypi/PyMySQL" # Replace with a single Tidelift platform-name/package-name e.g., npm/babel
community_bridge: # Replace with a single Community Bridge project-name e.g., cloud-foundry
liberapay: # Replace with a single Liberapay username
issuehunt: # Replace with a single IssueHunt username
Expand Down
11 changes: 7 additions & 4 deletions .github/workflows/lint.yaml
Expand Up @@ -10,13 +10,16 @@ on:

jobs:
lint:
runs-on: ubuntu-20.04
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/setup-python@v2
- uses: actions/checkout@v3
- uses: actions/setup-python@v4
with:
python-version: 3.x
- uses: psf/black@stable
with:
args: ". --diff --check"
options: "--check --verbose"
src: "."
- name: Setup flake8 annotations
uses: rbialon/flake8-annotations@v1
- name: flake8
Expand Down
7 changes: 4 additions & 3 deletions .github/workflows/lock.yml
Expand Up @@ -2,15 +2,16 @@ name: 'Lock Threads'

on:
schedule:
- cron: '0 0 * * *'
- cron: '30 9 * * 1'

permissions:
issues: write
pull-requests: write

jobs:
action:
lock-threads:
if: github.repository == 'PyMySQL/PyMySQL'
runs-on: ubuntu-latest
steps:
- uses: dessant/lock-threads@v2
- uses: dessant/lock-threads@v4

26 changes: 18 additions & 8 deletions .github/workflows/test.yaml
Expand Up @@ -10,7 +10,7 @@ concurrency:

jobs:
test:
runs-on: ubuntu-20.04
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
Expand All @@ -22,7 +22,7 @@ jobs:
py: "3.7"

- db: "mariadb:10.7"
py: "3.11-dev"
py: "3.11"

- db: "mariadb:10.8"
py: "3.9"
Expand All @@ -45,19 +45,28 @@ jobs:
env:
MYSQL_ALLOW_EMPTY_PASSWORD: yes
options: "--name=mysqld"
volumes:
- /run/mysqld:/run/mysqld

steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3

- name: Workaround MySQL container permissions
if: startsWith(matrix.db, 'mysql')
run: |
sudo chown 999:999 /run/mysqld
/usr/bin/docker ps --all --filter status=exited --no-trunc --format "{{.ID}}" | xargs -r /usr/bin/docker start
- name: Set up Python ${{ matrix.py }}
uses: actions/setup-python@v2
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.py }}
cache: 'pip'
cache-dependency-path: 'requirements-dev.txt'

- name: Install dependency
run: |
pip install -U -r requirements-dev.txt
pip install --upgrade -r requirements-dev.txt
- name: Set up MySQL
run: |
Expand All @@ -75,6 +84,7 @@ jobs:
- name: Run test
run: |
pytest -v --cov --cov-config .coveragerc pymysql
pytest -v --cov-append --cov-config .coveragerc --doctest-modules pymysql/converters.py
- name: Run MySQL8 auth test
if: ${{ matrix.mysql_auth }}
Expand All @@ -97,16 +107,16 @@ jobs:
coveralls:
if: github.repository == 'PyMySQL/PyMySQL'
name: Finish coveralls
runs-on: ubuntu-20.04
runs-on: ubuntu-latest
needs: test
steps:
- name: requirements.
run: |
echo coveralls > requirements.txt
- uses: actions/setup-python@v2
- uses: actions/setup-python@v4
with:
python-version: '3.9'
python-version: '3.x'
cache: 'pip'

- name: Finished
Expand Down
2 changes: 1 addition & 1 deletion CHANGELOG.md
Expand Up @@ -205,7 +205,7 @@ Release date: 2016-08-30
Release date: 2016-07-29

* Fix SELECT JSON type cause UnicodeError
* Avoid float convertion while parsing microseconds
* Avoid float conversion while parsing microseconds
* Warning has number
* SSCursor supports warnings

Expand Down
2 changes: 1 addition & 1 deletion MANIFEST.in
@@ -1 +1 @@
include README.rst LICENSE CHANGELOG.md
include README.md LICENSE CHANGELOG.md
105 changes: 105 additions & 0 deletions README.md
@@ -0,0 +1,105 @@
[![Documentation Status](https://readthedocs.org/projects/pymysql/badge/?version=latest)](https://pymysql.readthedocs.io/)
[![image](https://coveralls.io/repos/PyMySQL/PyMySQL/badge.svg?branch=main&service=github)](https://coveralls.io/github/PyMySQL/PyMySQL?branch=main)

# PyMySQL

This package contains a pure-Python MySQL client library, based on [PEP
249](https://www.python.org/dev/peps/pep-0249/).

## Requirements

- Python -- one of the following:
- [CPython](https://www.python.org/) : 3.7 and newer
- [PyPy](https://pypy.org/) : Latest 3.x version
- MySQL Server -- one of the following:
- [MySQL](https://www.mysql.com/) \>= 5.7
- [MariaDB](https://mariadb.org/) \>= 10.3

## Installation

Package is uploaded on [PyPI](https://pypi.org/project/PyMySQL).

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](https://stackoverflow.com/questions/tagged/pymysql).

## Example

The following examples make use of a simple table

``` sql
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 ;
```

``` python
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:

``` python
{'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.
141 changes: 0 additions & 141 deletions README.rst

This file was deleted.

0 comments on commit a5e84c1

Please sign in to comment.