Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
85 changes: 52 additions & 33 deletions AGENTS.md
Original file line number Diff line number Diff line change
@@ -1,49 +1,68 @@
## Rule
## Checks before committing

Do `ruff format` and `ruff check` before commit.
Run commands from the repository root. Format and lint the source before
committing:

## Running the MySQL test suite in this container
```sh
ruff format src/
ruff check src/
git diff --check
```

1. Install the server and test dependencies if they are not already available:
## Running the mysqlclient test suite

```sh
apt-get update
DEBIAN_FRONTEND=noninteractive apt-get install -y mysql-server
python -m pip install --upgrade -r requirements-dev.txt
```
The CI configuration is in [.github/workflows/tests.yaml](.github/workflows/tests.yaml).
The package is in `src/MySQLdb/` and the tests are in `tests/`.

1. Install a C compiler, Python development headers, `pkg-config`, and MySQL or
MariaDB client development libraries, as described in [README.md](README.md).
A running MySQL or MariaDB server is also required for database tests.

2. Keep MySQL running in a separate, long-lived terminal/session. The container
does not run systemd, so start `mysqld` directly instead of using
`systemctl`:
2. In a Python virtual environment, install the package and test dependencies:

```sh
install -d -o mysql -g mysql /run/mysqld
rm -f /run/mysqld/mysqld.sock /run/mysqld/mysqld.sock.lock \
/run/mysqld/mysqlx.sock /run/mysqld/mysqlx.sock.lock \
/run/mysqld/mysqld.pid
mysqld --user=mysql --local-infile=1 \
--socket=/run/mysqld/mysqld.sock \
--pid-file=/run/mysqld/mysqld.pid
python -m pip install -v .
python -m pip install -r requirements.txt
python -m pip install "SQLAlchemy>=2,<3"
```

3. In another terminal/session, wait for MySQL and initialize a fresh data
directory. The SQL files create databases and users, so only run them when
`test1` does not exist:
SQLAlchemy is needed to run `tests/test_sqlalchemy.py`; those tests are
skipped if it is not installed.

3. Start the database server using the service manager available in your
environment. In containers without a service manager, run `mysqld` in a
separate, long-lived terminal with an initialized data directory and writable
socket and PID file locations.

Create a dedicated test database using an administrator connection, for example:

```sh
until mysqladmin ping --silent; do sleep 1; done
if ! mysql -NBe "SHOW DATABASES LIKE 'test1'" | rg -q '^test1$'; then
mysql -uroot --comments < ci/docker-entrypoint-initdb.d/init.sql
mysql -uroot --comments < ci/docker-entrypoint-initdb.d/mysql.sql
mysql -uroot --comments < ci/docker-entrypoint-initdb.d/mariadb.sql
fi
cp ci/docker.json pymysql/tests/databases.json
mysql -uroot -p -e "CREATE DATABASE IF NOT EXISTS mysqldb_test"
```

4. Run the same test commands as CI:
The test user needs to create, alter, and drop tables, run `SELECT`,
`INSERT`, `UPDATE`, and `DELETE`, and create, execute, and drop stored
procedures in that database.
`tests/actions.cnf` uses `127.0.0.1:3306`, user `root`, password `root`, and
database `mysqldb_test`. For different credentials, create a separate MySQL
option file with a `[MySQLdb-tests]` group, using `tests/actions.cnf` as a
template.

4. Run the same pytest command as CI:

```sh
pytest -v --cov --cov-config .coveragerc pymysql
pytest -v --cov-append --cov-config .coveragerc \
--doctest-modules pymysql/converters.py
TESTDB=actions.cnf pytest --cov=MySQLdb tests
```

`TESTDB` selects a filename under `tests/` or an absolute path to an option
file. Without it, `tests/default.cnf` is used. The tests create and drop
tables, so use the dedicated test database.

CI also runs the Django test suite in a separate job. Refer to
`.github/workflows/tests.yaml` for its dependencies, database setup, and
`test_mysql_executemany_multi` settings.

## Releases

Follow [notes/release.md](notes/release.md) for version updates, release CI,
tagging, and publication.
19 changes: 19 additions & 0 deletions HISTORY.rst
Original file line number Diff line number Diff line change
@@ -1,3 +1,22 @@
======================
What's new in 2.3.2
======================

Release: 2026-11-18

* Restore the use of the base type's literal conversion for subclasses of
``str``, ``bytes``, and ``bytearray``. This fixes a regression in 2.3.1 where string-valued
``enum.Enum`` members were serialized using their enum names instead of their
string values. (#814)

* Avoid a spurious ``ProgrammingError`` when another thread drops the last
reference to a buffered result while the connection is in use. (#815)

* Escape the contents of ``bytearray`` query parameters the same way as
``bytes``. Previously, passing ``bytearray(b'ab')`` sent the Python string
representation to the server. This also applies to subclasses. (#817)


======================
What's new in 2.3.1
======================
Expand Down
4 changes: 2 additions & 2 deletions src/MySQLdb/release.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
__author__ = "Inada Naoki <songofacandy@gmail.com>"
__version__ = "2.3.1"
version_info = (2, 3, 1, "final", 0)
__version__ = "2.3.2"
version_info = (2, 3, 2, "final", 0)
Loading