Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: Lawrence-git/PyMySQL
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: 3674bc6
Choose a base ref
...
head repository: PyMySQL/PyMySQL
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: 01af30f
Choose a head ref
Loading
Showing with 4,245 additions and 3,201 deletions.
  1. +1 −0 .coveragerc
  2. +12 −0 .github/FUNDING.yml
  3. +0 −11 .github/ISSUE_TEMPLATE.md
  4. +39 −0 .github/ISSUE_TEMPLATE/bug_report.md
  5. +66 −0 .github/workflows/django.yaml
  6. +24 −0 .github/workflows/lint.yaml
  7. +110 −0 .github/workflows/test.yaml
  8. +1 −0 .gitignore
  9. +17 −0 .readthedocs.yaml
  10. +0 −67 .travis.yml
  11. +0 −4 .travis/database.json
  12. +0 −4 .travis/docker.json
  13. +0 −46 .travis/initializedb.sh
  14. +124 −3 CHANGELOG → CHANGELOG.md
  15. +1 −1 MANIFEST.in
  16. +106 −0 README.md
  17. +0 −150 README.rst
  18. +5 −0 SECURITY.md
  19. +4 −0 ci/database.json
  20. +12 −0 ci/docker-entrypoint-initdb.d/README
  21. +7 −0 ci/docker-entrypoint-initdb.d/init.sql
  22. +2 −0 ci/docker-entrypoint-initdb.d/mariadb.sql
  23. +8 −0 ci/docker-entrypoint-initdb.d/mysql.sql
  24. +5 −0 ci/docker.json
  25. +47 −0 ci/test_mysql.py
  26. +7 −0 codecov.yml
  27. +0 −24 docs/Makefile
  28. +0 −242 docs/make.bat
  29. +2 −0 docs/requirements.txt
  30. +84 −73 docs/source/conf.py
  31. +2 −2 docs/source/index.rst
  32. +5 −9 docs/source/user/development.rst
  33. +5 −6 docs/source/user/examples.rst
  34. +4 −4 docs/source/user/installation.rst
  35. +1 −4 example.py
  36. +116 −74 pymysql/__init__.py
  37. +78 −71 pymysql/_auth.py
  38. +0 −21 pymysql/_compat.py
  39. +0 −134 pymysql/_socketio.py
  40. +177 −172 pymysql/charset.py
  41. +464 −295 pymysql/connections.py
  42. +10 −3 pymysql/constants/CLIENT.py
  43. +12 −13 pymysql/constants/COMMAND.py
  44. +62 −51 pymysql/constants/CR.py
  45. +3 −1 pymysql/constants/ER.py
  46. +0 −2 pymysql/constants/FIELD_TYPE.py
  47. +0 −1 pymysql/constants/SERVER_STATUS.py
  48. +114 −121 pymysql/converters.py
  49. +136 −110 pymysql/cursors.py
  50. +67 −21 pymysql/err.py
  51. +6 −8 pymysql/optionfile.py
  52. +85 −70 pymysql/protocol.py
  53. +0 −18 pymysql/tests/__init__.py
  54. +28 −38 pymysql/tests/base.py
  55. +33 −25 pymysql/tests/test_DictCursor.py
  56. +178 −52 pymysql/tests/test_SSCursor.py
  57. +164 −86 pymysql/tests/test_basic.py
  58. +44 −0 pymysql/tests/test_charset.py
  59. +549 −182 pymysql/tests/test_connection.py
  60. +10 −23 pymysql/tests/test_converters.py
  61. +146 −32 pymysql/tests/test_cursor.py
  62. +12 −11 pymysql/tests/test_err.py
  63. +118 −107 pymysql/tests/test_issues.py
  64. +48 −13 pymysql/tests/test_load_local.py
  65. +7 −8 pymysql/tests/test_nextset.py
  66. +7 −16 pymysql/tests/test_optionfile.py
  67. +1 −0 pymysql/tests/thirdparty/__init__.py
  68. +1 −2 pymysql/tests/thirdparty/test_MySQLdb/__init__.py
  69. +139 −124 pymysql/tests/thirdparty/test_MySQLdb/capabilities.py
  70. +405 −403 pymysql/tests/thirdparty/test_MySQLdb/dbapi20.py
  71. +44 −33 pymysql/tests/thirdparty/test_MySQLdb/test_MySQLdb_capabilities.py
  72. +108 −95 pymysql/tests/thirdparty/test_MySQLdb/test_MySQLdb_dbapi20.py
  73. +31 −30 pymysql/tests/thirdparty/test_MySQLdb/test_MySQLdb_nonstandard.py
  74. +0 −13 pymysql/util.py
  75. +67 −0 pyproject.toml
  76. +7 −0 renovate.json
  77. +2 −0 requirements-dev.txt
  78. +0 −17 setup.cfg
  79. +0 −38 setup.py
  80. +65 −8 tests/test_auth.py
  81. +0 −9 tox.ini
1 change: 1 addition & 0 deletions .coveragerc
Original file line number Diff line number Diff line change
@@ -2,6 +2,7 @@
branch = True
source =
pymysql
tests
omit = pymysql/tests/*
pymysql/tests/thirdparty/test_MySQLdb/*

12 changes: 12 additions & 0 deletions .github/FUNDING.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# These are supported funding model platforms

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: "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
otechie: # Replace with a single Otechie username
custom: # Replace with up to 4 custom sponsorship URLs e.g., ['link1', 'link2']
11 changes: 0 additions & 11 deletions .github/ISSUE_TEMPLATE.md

This file was deleted.

39 changes: 39 additions & 0 deletions .github/ISSUE_TEMPLATE/bug_report.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
---
name: Bug report
about: Create a report to help us improve
title: ''
labels: ''
assignees: ''

---

**Describe the bug**
A clear and concise description of what the bug is.

**To Reproduce**
Complete steps to reproduce the behavior:

Schema:

```
CREATE DATABASE ...
CREATE TABLE ...
```

Code:

```py
import pymysql
con = pymysql.connect(...)
```

**Expected behavior**
A clear and concise description of what you expected to happen.

**Environment**
- OS: [e.g. Windows, Linux]
- Server and version: [e.g. MySQL 8.0.19, MariaDB]
- PyMySQL version:

**Additional context**
Add any other context about the problem here.
66 changes: 66 additions & 0 deletions .github/workflows/django.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
name: Django test

on:
push:
# branches: ["main"]
# pull_request:

jobs:
django-test:
name: "Run Django LTS test suite"
runs-on: ubuntu-latest
# There are some known difference between MySQLdb and PyMySQL.
continue-on-error: true
env:
PIP_NO_PYTHON_VERSION_WARNING: 1
PIP_DISABLE_PIP_VERSION_CHECK: 1
# DJANGO_VERSION: "3.2.19"
strategy:
fail-fast: false
matrix:
include:
# Django 3.2.9+ supports Python 3.10
# https://docs.djangoproject.com/ja/3.2/releases/3.2/
- django: "3.2.19"
python: "3.10"

- django: "4.2.1"
python: "3.11"

steps:
- name: Start MySQL
run: |
sudo systemctl start mysql.service
mysql_tzinfo_to_sql /usr/share/zoneinfo | mysql -uroot -proot mysql
mysql -uroot -proot -e "set global innodb_flush_log_at_trx_commit=0;"
mysql -uroot -proot -e "CREATE USER 'scott'@'%' IDENTIFIED BY 'tiger'; GRANT ALL ON *.* TO scott;"
mysql -uroot -proot -e "CREATE DATABASE django_default; CREATE DATABASE django_other;"
- uses: actions/checkout@v4

- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python }}

- name: Install mysqlclient
run: |
#pip install mysqlclient # Use stable version
pip install .[rsa]
- name: Setup Django
run: |
sudo apt-get install libmemcached-dev
wget https://github.com/django/django/archive/${{ matrix.django }}.tar.gz
tar xf ${{ matrix.django }}.tar.gz
cp ci/test_mysql.py django-${{ matrix.django }}/tests/
cd django-${{ matrix.django }}
pip install . -r tests/requirements/py3.txt
- name: Run Django test
run: |
cd django-${{ matrix.django }}/tests/
# test_runner does not using our test_mysql.py
# We can't run whole django test suite for now.
# Run olly backends test
DJANGO_SETTINGS_MODULE=test_mysql python runtests.py backends
24 changes: 24 additions & 0 deletions .github/workflows/lint.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
name: Lint

on:
push:
branches: ["main"]
paths:
- '**.py'
pull_request:
paths:
- '**.py'

jobs:
lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- uses: astral-sh/ruff-action@v3

- name: format
run: ruff format --diff

- name: lint
run: ruff check --diff
110 changes: 110 additions & 0 deletions .github/workflows/test.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,110 @@
name: Test

on:
push:
pull_request:

concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.sha }}
cancel-in-progress: true

env:
FORCE_COLOR: 1

jobs:
test:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
include:
- db: "mariadb:10.4"
py: "3.13"

- db: "mariadb:10.5"
py: "3.11"

- db: "mariadb:10.6"
py: "3.10"

- db: "mariadb:10.6"
py: "3.9"

- db: "mariadb:lts"
py: "3.8"

- db: "mysql:5.7"
py: "pypy-3.10"

- db: "mysql:8.0"
py: "3.13"
mysql_auth: true

- db: "mysql:8.4"
py: "3.8"
mysql_auth: true

services:
mysql:
image: "${{ matrix.db }}"
ports:
- 3306:3306
env:
MYSQL_ALLOW_EMPTY_PASSWORD: yes
MARIADB_ALLOW_EMPTY_ROOT_PASSWORD: yes
options: "--name=mysqld"
volumes:
- /run/mysqld:/run/mysqld

steps:
- uses: actions/checkout@v4

- 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@v5
with:
python-version: ${{ matrix.py }}
allow-prereleases: true
cache: 'pip'
cache-dependency-path: 'requirements-dev.txt'

- name: Install dependency
run: |
pip install --upgrade -r requirements-dev.txt
- name: Set up MySQL
run: |
while :
do
sleep 1
mysql -h127.0.0.1 -uroot -e 'select version()' && break
done
mysql -h127.0.0.1 -uroot -e "SET GLOBAL local_infile=on"
mysql -h127.0.0.1 -uroot --comments < ci/docker-entrypoint-initdb.d/init.sql
mysql -h127.0.0.1 -uroot --comments < ci/docker-entrypoint-initdb.d/mysql.sql
mysql -h127.0.0.1 -uroot --comments < ci/docker-entrypoint-initdb.d/mariadb.sql
cp ci/docker.json pymysql/tests/databases.json
- 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 }}
run: |
docker cp mysqld:/var/lib/mysql/public_key.pem "${HOME}"
docker cp mysqld:/var/lib/mysql/ca.pem "${HOME}"
docker cp mysqld:/var/lib/mysql/server-cert.pem "${HOME}"
docker cp mysqld:/var/lib/mysql/client-key.pem "${HOME}"
docker cp mysqld:/var/lib/mysql/client-cert.pem "${HOME}"
pytest -v --cov-append --cov-config .coveragerc tests/test_auth.py;
- name: Upload coverage reports to Codecov
if: github.repository == 'PyMySQL/PyMySQL'
uses: codecov/codecov-action@v5
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -13,3 +13,4 @@
/pymysql/tests/databases.json
__pycache__
Pipfile.lock
pdm.lock
17 changes: 17 additions & 0 deletions .readthedocs.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# .readthedocs.yaml
# Read the Docs configuration file
# See https://docs.readthedocs.io/en/stable/config-file/v2.html for details
version: 2

build:
os: ubuntu-22.04
tools:
python: "3.12"

python:
install:
- requirements: docs/requirements.txt

# Build documentation in the docs/ directory with Sphinx
sphinx:
configuration: docs/source/conf.py
67 changes: 0 additions & 67 deletions .travis.yml

This file was deleted.

4 changes: 0 additions & 4 deletions .travis/database.json

This file was deleted.

4 changes: 0 additions & 4 deletions .travis/docker.json

This file was deleted.

Loading