From eb5cb3d564e8eec632b51147dfb8c929fbd05fd1 Mon Sep 17 00:00:00 2001 From: Mario Haustein Date: Thu, 22 Jun 2023 15:10:48 +0200 Subject: [PATCH 01/19] Add build dependency for `pkg-config` to README (#621) Fix #620 --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index d8ed79ca..c7dc4855 100644 --- a/README.md +++ b/README.md @@ -71,8 +71,8 @@ support in some user forum. Don't file a issue on the issue tracker.** You may need to install the Python 3 and MySQL development headers and libraries like so: -* `$ sudo apt-get install python3-dev default-libmysqlclient-dev build-essential` # Debian / Ubuntu -* `% sudo yum install python3-devel mysql-devel` # Red Hat / CentOS +* `$ sudo apt-get install python3-dev default-libmysqlclient-dev build-essential pkg-config` # Debian / Ubuntu +* `% sudo yum install python3-devel mysql-devel pkgconfig` # Red Hat / CentOS Then you can install mysqlclient via pip now: From df302ff62f154a85221fa9f424765fbac35026aa Mon Sep 17 00:00:00 2001 From: Inada Naoki Date: Fri, 23 Jun 2023 04:04:59 +0900 Subject: [PATCH 02/19] Add discussion template --- .github/DISCUSSION_TEMPLATE/build.yml | 49 +++++++++++++++++++++++++++ 1 file changed, 49 insertions(+) create mode 100644 .github/DISCUSSION_TEMPLATE/build.yml diff --git a/.github/DISCUSSION_TEMPLATE/build.yml b/.github/DISCUSSION_TEMPLATE/build.yml new file mode 100644 index 00000000..c2e93df4 --- /dev/null +++ b/.github/DISCUSSION_TEMPLATE/build.yml @@ -0,0 +1,49 @@ +title: "[Build] " +body: + - type: input + id: os + attributes: + label: What OS and which version do you use? + description: | + e.g. + - Windows 11 + - macOS 13.4 + - Ubuntu 22.04 + + - type: textarea + id: libmysqlclient + attributes: + label: How did you installed mysql client library? + description: | + e.g. + - `apt-get install libmysqlclient-dev` + - `brew install mysql-client` + - `brew install mysql` + render: bash + + - type: textarea + id: pkgconfig-output + attributes: + label: Output from `pkg-config --cflags --libs mysqlclient` + description: If you are using mariadbclient, run `pkg-config --cflags --libs mariadb` instead. + render: bash + + - type: input + id: mysqlclient-install + attributes: + label: How did you tried to install mysqlclient? + description: | + e.g. + - `pip install mysqlclient` + - `poetry add mysqlclient` + + - type: textarea + id: mysqlclient-error + attributes: + label: Output of building mysqlclient + description: not only error message. full log from start installing mysqlclient. + render: bash + + + + From 020f040ce169d05331c64fca64198f752fae8f69 Mon Sep 17 00:00:00 2001 From: Inada Naoki Date: Fri, 23 Jun 2023 04:09:24 +0900 Subject: [PATCH 03/19] Add issue template config --- .github/ISSUE_TEMPLATE/config.yml | 4 ++++ 1 file changed, 4 insertions(+) create mode 100644 .github/ISSUE_TEMPLATE/config.yml diff --git a/.github/ISSUE_TEMPLATE/config.yml b/.github/ISSUE_TEMPLATE/config.yml new file mode 100644 index 00000000..6116b043 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/config.yml @@ -0,0 +1,4 @@ +contact_links: + - name: Failed to build + url: "https://github.com/PyMySQL/mysqlclient/discussions/new?category=build" + about: Ask help in this forum. From 1b29c60d449d1822936dc535c19be7f3c1d46848 Mon Sep 17 00:00:00 2001 From: Inada Naoki Date: Fri, 23 Jun 2023 05:05:24 +0900 Subject: [PATCH 04/19] Update bugreport issue template --- .github/ISSUE_TEMPLATE/bug_report.md | 58 ----------------- .github/ISSUE_TEMPLATE/bugreport.yml | 93 ++++++++++++++++++++++++++++ 2 files changed, 93 insertions(+), 58 deletions(-) delete mode 100644 .github/ISSUE_TEMPLATE/bug_report.md create mode 100644 .github/ISSUE_TEMPLATE/bugreport.yml diff --git a/.github/ISSUE_TEMPLATE/bug_report.md b/.github/ISSUE_TEMPLATE/bug_report.md deleted file mode 100644 index 50d2bdc2..00000000 --- a/.github/ISSUE_TEMPLATE/bug_report.md +++ /dev/null @@ -1,58 +0,0 @@ ---- -name: Bug report -about: Report an issue of this project -title: '' -labels: '' -assignees: '' - ---- - -### Read this first - -We don't use this issue tracker to help users. If you had trouble, please ask it on some user community. See [here](https://github.com/PyMySQL/mysqlclient-python#support). -Please use this tracker only when you are sure about it is an issue of this software. - -And please provide full information from first. I don't want to ask questions like "What is your Python version?", "Do you confirm MySQL error log?". If the issue report looks incomplete, I will just close it. - -Are you ready? Please remove until here and make a good issue report!! - - -### Describe the bug - -A clear and concise description of what the bug is. - -### To Reproduce - -**Schema** - -``` -create table .... -``` - -**Code** - -```py -con = MySQLdb.connect(...) -cur = con.cursor() -cur.execute(...) -``` - -### Environment - -**MySQL Server** - -- Server OS (e.g. Windows 10, Ubuntu 20.04): -- Server Version (e.g. MariaDB 10.3.16): - -**MySQL Client** - -- OS (e.g. Windows 10, Ubuntu 20.04): - -- Python (e.g. Homebrew Python 3.7.5): - -- Connector/C (e.g. Homebrew mysql-client 8.0.18): - - -### Additional context - -Add any other context about the problem here. diff --git a/.github/ISSUE_TEMPLATE/bugreport.yml b/.github/ISSUE_TEMPLATE/bugreport.yml new file mode 100644 index 00000000..a3dc04a3 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/bugreport.yml @@ -0,0 +1,93 @@ +name: Bug Report +description: File a bug report +body: + - type: markdown + attributes: + value: | + We don't use this issue tracker to help users. + Please use this tracker only when you are sure about it is an issue of this software. + + If you had trouble, please ask it on some user community. + + - [Python Discord](https://www.pythondiscord.com/) + For general Python questions, including developing application using MySQL. + + - [MySQL Community Slack](https://lefred.be/mysql-community-on-slack/) + For general MySQL questions. + + - [mysqlclient Discuss](https://github.com/PyMySQL/mysqlclient/discussions) + For mysqlclient specific topics. + + - type: textarea + id: describe + attributes: + label: Describe the bug + description: "A **clear and concise** description of what the bug is." + + - type: textarea + id: environments + attributes: + label: Environment + description: | + - Server and version (e.g. MySQL 8.0.33, MariaDB 10.11.4) + - OS (e.g. Windows 11, Ubuntu 22.04, macOS 13.4.1) + - Python version + + - type: input + id: libmysqlclient + attributes: + label: How did you install libmysqlclient libraries? + description: | + e.g. brew install mysql-cleint, brew install mariadb, apt-get install libmysqlclient-dev + + - type: input + id: mysqlclient-version + attributes: + label: What version of mysqlclient do you use? + + - type: markdown + attributes: + value: | + ## Complete step to reproduce. + # + Do not expect maintainer complement any piece of code, schema, and data need to reproduce. + You need to provide **COMPLETE** step to reproduce. + + It is very recommended to use Docker to start MySQL server. + Maintainer can not use your Database to reproduce your issue. + + **If you write only little code snippet, maintainer may close your issue + without any comment.** + + - type: textarea + id: reproduce-docker + attributes: + label: Docker command to start MySQL server + render: bash + description: e.g. `docker run -e MYSQL_ALLOW_EMPTY_PASSWORD=yes -p 3306:3306 --rm --name mysql mysql:8.0` + + - type: textarea + id: reproduce-code + attributes: + label: Minimum but complete code to reproduce + render: python + value: | + # Write Python code here. + import MySQLdb + + conn = MySQLdb.connect(host='127.0.0.1', port=3306, user='root') + ... + + - type: textarea + id: reproduce-schema + attributes: + label: Schema and initial data required to reproduce. + render: sql + value: | + -- Write SQL here. + -- e.g. CREATE TABLE ... + + - type: textarea + id: reproduce-other + attributes: + label: Commands, and any other step required to reproduce your issue. From 4f2a8393c79a1ef18db8bb874f205145fa272f73 Mon Sep 17 00:00:00 2001 From: Inada Naoki Date: Fri, 23 Jun 2023 05:07:28 +0900 Subject: [PATCH 05/19] update issue config --- .github/ISSUE_TEMPLATE/config.yml | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/.github/ISSUE_TEMPLATE/config.yml b/.github/ISSUE_TEMPLATE/config.yml index 6116b043..198b7e02 100644 --- a/.github/ISSUE_TEMPLATE/config.yml +++ b/.github/ISSUE_TEMPLATE/config.yml @@ -1,4 +1,8 @@ contact_links: - name: Failed to build + about: Ask help for build error. url: "https://github.com/PyMySQL/mysqlclient/discussions/new?category=build" - about: Ask help in this forum. + + - name: Ask question + about: Ask other questions. + url: "https://github.com/PyMySQL/mysqlclient/discussions/new?category=q-a" From 807933eb2547f26b9adb5c72960d99c791d8021b Mon Sep 17 00:00:00 2001 From: Inada Naoki Date: Thu, 29 Jun 2023 17:36:30 +0900 Subject: [PATCH 06/19] Support pkg-config libmariadb (#631) Fix #629. --- setup.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/setup.py b/setup.py index 2fa4cbbd..f7f3d924 100644 --- a/setup.py +++ b/setup.py @@ -14,7 +14,8 @@ def find_package_name(): """Get available pkg-config package name""" - packages = ["mysqlclient", "mariadb"] + # Ubuntu uses mariadb.pc, but CentOS uses libmariadb.pc + packages = ["mysqlclient", "mariadb", "libmariadb"] for pkg in packages: try: cmd = f"pkg-config --exists {pkg}" @@ -153,7 +154,7 @@ def get_options(): else: ext_options = get_config_posix(get_options()) -print("# Options for building extention module:") +print("# Options for building extension module:") for k, v in ext_options.items(): print(f" {k}: {v}") From 1468dce0737d1d042fd5431bb048ff13a51cc936 Mon Sep 17 00:00:00 2001 From: raceybe Date: Thu, 29 Jun 2023 23:22:35 -0400 Subject: [PATCH 07/19] Update README.md (#633) fixed typo in Customize build (POSIX) --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index c7dc4855..c6c8a5a8 100644 --- a/README.md +++ b/README.md @@ -82,7 +82,7 @@ $ pip install mysqlclient ### Customize build (POSIX) -mysqlclient uses `pkg-config --clfags --ldflags mysqlclient` by default for finding +mysqlclient uses `pkg-config --cflags --ldflags mysqlclient` by default for finding compiler/linker flags. You can use `MYSQLCLIENT_CFLAGS` and `MYSQLCLIENT_LDFLAGS` environment From 8878212ee94e905b33333988f411faeb96e6f538 Mon Sep 17 00:00:00 2001 From: Inada Naoki Date: Sun, 2 Jul 2023 03:04:28 +0900 Subject: [PATCH 08/19] Move issue report to discussions --- .../bugreport.yml => DISCUSSION_TEMPLATE/issue-report.yml} | 4 ++-- .github/ISSUE_TEMPLATE/config.yml | 4 ++++ 2 files changed, 6 insertions(+), 2 deletions(-) rename .github/{ISSUE_TEMPLATE/bugreport.yml => DISCUSSION_TEMPLATE/issue-report.yml} (96%) diff --git a/.github/ISSUE_TEMPLATE/bugreport.yml b/.github/DISCUSSION_TEMPLATE/issue-report.yml similarity index 96% rename from .github/ISSUE_TEMPLATE/bugreport.yml rename to .github/DISCUSSION_TEMPLATE/issue-report.yml index a3dc04a3..1e4d293c 100644 --- a/.github/ISSUE_TEMPLATE/bugreport.yml +++ b/.github/DISCUSSION_TEMPLATE/issue-report.yml @@ -1,9 +1,9 @@ -name: Bug Report -description: File a bug report body: - type: markdown attributes: value: | + Failed to buid? [Use this form](https://github.com/PyMySQL/mysqlclient/discussions/new?category=build). + We don't use this issue tracker to help users. Please use this tracker only when you are sure about it is an issue of this software. diff --git a/.github/ISSUE_TEMPLATE/config.yml b/.github/ISSUE_TEMPLATE/config.yml index 198b7e02..dc88cb1a 100644 --- a/.github/ISSUE_TEMPLATE/config.yml +++ b/.github/ISSUE_TEMPLATE/config.yml @@ -3,6 +3,10 @@ contact_links: about: Ask help for build error. url: "https://github.com/PyMySQL/mysqlclient/discussions/new?category=build" + - name: Report issue + about: Found bug? + url: "https://github.com/PyMySQL/mysqlclient/discussions/new?category=issue-report" + - name: Ask question about: Ask other questions. url: "https://github.com/PyMySQL/mysqlclient/discussions/new?category=q-a" From fc6b9da632fa6cd7170e77421ecf86653817327f Mon Sep 17 00:00:00 2001 From: Inada Naoki Date: Sun, 2 Jul 2023 03:07:09 +0900 Subject: [PATCH 09/19] fix templates --- .github/DISCUSSION_TEMPLATE/{build.yml => build-issue.yml} | 0 .github/DISCUSSION_TEMPLATE/issue-report.yml | 2 +- .github/ISSUE_TEMPLATE/config.yml | 2 +- 3 files changed, 2 insertions(+), 2 deletions(-) rename .github/DISCUSSION_TEMPLATE/{build.yml => build-issue.yml} (100%) diff --git a/.github/DISCUSSION_TEMPLATE/build.yml b/.github/DISCUSSION_TEMPLATE/build-issue.yml similarity index 100% rename from .github/DISCUSSION_TEMPLATE/build.yml rename to .github/DISCUSSION_TEMPLATE/build-issue.yml diff --git a/.github/DISCUSSION_TEMPLATE/issue-report.yml b/.github/DISCUSSION_TEMPLATE/issue-report.yml index 1e4d293c..6724fcf8 100644 --- a/.github/DISCUSSION_TEMPLATE/issue-report.yml +++ b/.github/DISCUSSION_TEMPLATE/issue-report.yml @@ -2,7 +2,7 @@ body: - type: markdown attributes: value: | - Failed to buid? [Use this form](https://github.com/PyMySQL/mysqlclient/discussions/new?category=build). + Failed to buid? [Use this form](https://github.com/PyMySQL/mysqlclient/discussions/new?category=build-issue). We don't use this issue tracker to help users. Please use this tracker only when you are sure about it is an issue of this software. diff --git a/.github/ISSUE_TEMPLATE/config.yml b/.github/ISSUE_TEMPLATE/config.yml index dc88cb1a..9f1273ed 100644 --- a/.github/ISSUE_TEMPLATE/config.yml +++ b/.github/ISSUE_TEMPLATE/config.yml @@ -1,7 +1,7 @@ contact_links: - name: Failed to build about: Ask help for build error. - url: "https://github.com/PyMySQL/mysqlclient/discussions/new?category=build" + url: "https://github.com/PyMySQL/mysqlclient/discussions/new?category=build-issue" - name: Report issue about: Found bug? From a72b7aa707fb457ef80b613ba08e0872b51e6f30 Mon Sep 17 00:00:00 2001 From: Stevie Gayet <87695919+stegayet@users.noreply.github.com> Date: Mon, 21 Aug 2023 10:54:30 +0200 Subject: [PATCH 10/19] ci: add Python 3.12 in test matrix (#644) --- .github/workflows/tests.yaml | 3 ++- pyproject.toml | 1 + 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/.github/workflows/tests.yaml b/.github/workflows/tests.yaml index c770ff9b..8380e09e 100644 --- a/.github/workflows/tests.yaml +++ b/.github/workflows/tests.yaml @@ -13,7 +13,7 @@ jobs: PIP_DISABLE_PIP_VERSION_CHECK: 1 strategy: matrix: - python-version: ["3.8", "3.9", "3.10", "3.11"] + python-version: ["3.8", "3.9", "3.10", "3.11", "3.12"] include: - python-version: "3.11" mariadb: 1 @@ -43,6 +43,7 @@ jobs: python-version: ${{ matrix.python-version }} cache: "pip" cache-dependency-path: "requirements.txt" + allow-prereleases: true - name: Install mysqlclient run: | diff --git a/pyproject.toml b/pyproject.toml index 3bfd1f6c..0ad7ae58 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -26,6 +26,7 @@ classifiers = [ "Programming Language :: Python :: 3.9", "Programming Language :: Python :: 3.10", "Programming Language :: Python :: 3.11", + "Programming Language :: Python :: 3.12", "Topic :: Database", "Topic :: Database :: Database Engines/Servers", ] From 91c04282eac46ce2e5380be58e262d817faab566 Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Wed, 13 Sep 2023 03:15:46 +0900 Subject: [PATCH 11/19] Update actions/checkout action to v4 (#654) --- .github/workflows/codeql.yml | 2 +- .github/workflows/lint.yaml | 2 +- .github/workflows/tests.yaml | 4 ++-- .github/workflows/windows.yaml | 2 +- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/.github/workflows/codeql.yml b/.github/workflows/codeql.yml index 9bab6e0c..b496b5a9 100644 --- a/.github/workflows/codeql.yml +++ b/.github/workflows/codeql.yml @@ -18,7 +18,7 @@ jobs: steps: - name: Checkout - uses: actions/checkout@v3 + uses: actions/checkout@v4 - name: Initialize CodeQL uses: github/codeql-action/init@v2 diff --git a/.github/workflows/lint.yaml b/.github/workflows/lint.yaml index 343b00fd..8e0e2947 100644 --- a/.github/workflows/lint.yaml +++ b/.github/workflows/lint.yaml @@ -9,6 +9,6 @@ jobs: lint: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - uses: psf/black@stable - uses: chartboost/ruff-action@v1 diff --git a/.github/workflows/tests.yaml b/.github/workflows/tests.yaml index 8380e09e..2ca99a3f 100644 --- a/.github/workflows/tests.yaml +++ b/.github/workflows/tests.yaml @@ -35,7 +35,7 @@ jobs: mysql --version mysql -uroot -proot -e "CREATE DATABASE mysqldb_test" - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - name: Set up Python ${{ matrix.python-version }} uses: actions/setup-python@v4 @@ -78,7 +78,7 @@ jobs: 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@v3 + - uses: actions/checkout@v4 - name: Set up Python uses: actions/setup-python@v4 diff --git a/.github/workflows/windows.yaml b/.github/workflows/windows.yaml index 23c04320..661b7793 100644 --- a/.github/workflows/windows.yaml +++ b/.github/workflows/windows.yaml @@ -40,7 +40,7 @@ jobs: cmake -DCMAKE_INSTALL_PREFIX=c:/mariadb-connector -DCMAKE_INSTALL_COMPONENT=Development -DCMAKE_BUILD_TYPE=Release -P cmake_install.cmake - name: Checkout mysqlclient - uses: actions/checkout@v3 + uses: actions/checkout@v4 with: path: mysqlclient From 0d0fff7662abf6e46324d26415ef3f4cb70f77db Mon Sep 17 00:00:00 2001 From: Inada Naoki Date: Mon, 13 Nov 2023 17:36:09 +0900 Subject: [PATCH 12/19] Do not use MYSQL_OPT_RECONNECT as possible. (#664) MySQL 8.0.33+ shows deprecation warning to stderr. So we avoid using it as possible. In the future, we will deprecate `reconnect` option of the `Connection.ping()`. --- src/MySQLdb/_mysql.c | 40 ++++++++++++++++++++++++-------------- src/MySQLdb/connections.py | 4 +++- 2 files changed, 28 insertions(+), 16 deletions(-) diff --git a/src/MySQLdb/_mysql.c b/src/MySQLdb/_mysql.c index cc419776..0612be26 100644 --- a/src/MySQLdb/_mysql.c +++ b/src/MySQLdb/_mysql.c @@ -25,13 +25,14 @@ USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ - +#include #include "mysql.h" #include "mysqld_error.h" #if MYSQL_VERSION_ID >= 80000 // https://github.com/mysql/mysql-server/commit/eb821c023cedc029ca0b06456dfae365106bee84 -#define my_bool _Bool +// my_bool was typedef of char before MySQL 8.0.0. +#define my_bool bool #endif #if ((MYSQL_VERSION_ID >= 50555 && MYSQL_VERSION_ID <= 50599) || \ @@ -71,7 +72,8 @@ static PyObject *_mysql_NotSupportedError; typedef struct { PyObject_HEAD MYSQL connection; - int open; + bool open; + bool reconnect; PyObject *converter; } _mysql_ConnectionObject; @@ -443,7 +445,8 @@ _mysql_ConnectionObject_Initialize( *auth_plugin=NULL; self->converter = NULL; - self->open = 0; + self->open = false; + self->reconnect = false; if (!PyArg_ParseTupleAndKeywords(args, kwargs, "|ssssisOiiisssiOsiiiss:connect", @@ -487,7 +490,7 @@ _mysql_ConnectionObject_Initialize( PyErr_SetNone(PyExc_MemoryError); return -1; } - self->open = 1; + self->open = true; if (connect_timeout) { unsigned int timeout = connect_timeout; @@ -686,7 +689,7 @@ _mysql_ConnectionObject_close( Py_BEGIN_ALLOW_THREADS mysql_close(&(self->connection)); Py_END_ALLOW_THREADS - self->open = 0; + self->open = false; _mysql_ConnectionObject_clear(self); Py_RETURN_NONE; } @@ -1852,18 +1855,18 @@ _mysql_ResultObject_num_rows( } static char _mysql_ConnectionObject_ping__doc__[] = -"Checks whether or not the connection to the server is\n\ -working. If it has gone down, an automatic reconnection is\n\ -attempted.\n\ +"Checks whether or not the connection to the server is working.\n\ \n\ This function can be used by clients that remain idle for a\n\ long while, to check whether or not the server has closed the\n\ -connection and reconnect if necessary.\n\ +connection.\n\ \n\ New in 1.2.2: Accepts an optional reconnect parameter. If True,\n\ then the client will attempt reconnection. Note that this setting\n\ is persistent. By default, this is on in MySQL<5.0.3, and off\n\ thereafter.\n\ +MySQL 8.0.33 deprecated the MYSQL_OPT_RECONNECT option so reconnect\n\ +parameter is also deprecated in mysqlclient 2.2.1.\n\ \n\ Non-standard. You should assume that ping() performs an\n\ implicit rollback; use only when starting a new transaction.\n\ @@ -1875,17 +1878,24 @@ _mysql_ConnectionObject_ping( _mysql_ConnectionObject *self, PyObject *args) { - int r, reconnect = -1; - if (!PyArg_ParseTuple(args, "|I", &reconnect)) return NULL; + int reconnect = 0; + if (!PyArg_ParseTuple(args, "|p", &reconnect)) return NULL; check_connection(self); - if (reconnect != -1) { + if (reconnect != (self->reconnect == true)) { + // libmysqlclient show warning to stderr when MYSQL_OPT_RECONNECT is used. + // so we avoid using it as possible for now. + // TODO: Warn when reconnect is true. + // MySQL 8.0.33 show warning to stderr already. + // We will emit Pytohn warning in future. my_bool recon = (my_bool)reconnect; mysql_options(&self->connection, MYSQL_OPT_RECONNECT, &recon); + self->reconnect = (bool)reconnect; } + int r; Py_BEGIN_ALLOW_THREADS r = mysql_ping(&(self->connection)); Py_END_ALLOW_THREADS - if (r) return _mysql_Exception(self); + if (r) return _mysql_Exception(self); Py_RETURN_NONE; } @@ -2165,7 +2175,7 @@ _mysql_ConnectionObject_dealloc( PyObject_GC_UnTrack(self); if (self->open) { mysql_close(&(self->connection)); - self->open = 0; + self->open = false; } Py_CLEAR(self->converter); MyFree(self); diff --git a/src/MySQLdb/connections.py b/src/MySQLdb/connections.py index 865d129a..7456aeac 100644 --- a/src/MySQLdb/connections.py +++ b/src/MySQLdb/connections.py @@ -192,7 +192,9 @@ class object, used to create cursors (keyword only) super().__init__(*args, **kwargs2) self.cursorclass = cursorclass - self.encoders = {k: v for k, v in conv.items() if type(k) is not int} + self.encoders = { + k: v for k, v in conv.items() if type(k) is not int # noqa: E721 + } self._server_version = tuple( [numeric_part(n) for n in self.get_server_info().split(".")[:2]] From cb236e9fefe211594a5f8e71eed26f0d36791105 Mon Sep 17 00:00:00 2001 From: Benjamin Loison <12752145+Benjamin-Loison@users.noreply.github.com> Date: Mon, 13 Nov 2023 09:53:15 +0100 Subject: [PATCH 13/19] add bash syntax highlighting to `README.md` (#665) --- README.md | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index c6c8a5a8..9c65ed7e 100644 --- a/README.md +++ b/README.md @@ -48,16 +48,16 @@ $ pip install mysqlclient Install MySQL and mysqlclient: -``` -# Assume you are activating Python 3 venv +```bash +$ # Assume you are activating Python 3 venv $ brew install mysql pkg-config $ pip install mysqlclient ``` If you don't want to install MySQL server, you can use mysql-client instead: -``` -# Assume you are activating Python 3 venv +```bash +$ # Assume you are activating Python 3 venv $ brew install mysql-client pkg-config $ export PKG_CONFIG_PATH="/opt/homebrew/opt/mysql-client/lib/pkgconfig" $ pip install mysqlclient @@ -88,7 +88,7 @@ compiler/linker flags. You can use `MYSQLCLIENT_CFLAGS` and `MYSQLCLIENT_LDFLAGS` environment variables to customize compiler/linker options. -``` +```bash $ export MYSQLCLIENT_CFLAGS=`pkg-config mysqlclient --cflags` $ export MYSQLCLIENT_LDFLAGS=`pkg-config mysqlclient --libs` $ pip install mysqlclient From 2e86ccec70b7863922d192afc3167718e4fb8714 Mon Sep 17 00:00:00 2001 From: Inada Naoki Date: Wed, 15 Nov 2023 19:14:04 +0900 Subject: [PATCH 14/19] use sphinx-rtd-theme (#668) --- .readthedocs.yaml | 6 ++++++ doc/conf.py | 6 +++--- doc/requirements.txt | 2 ++ 3 files changed, 11 insertions(+), 3 deletions(-) create mode 100644 doc/requirements.txt diff --git a/.readthedocs.yaml b/.readthedocs.yaml index eaffaf39..0b288620 100644 --- a/.readthedocs.yaml +++ b/.readthedocs.yaml @@ -4,6 +4,12 @@ build: os: ubuntu-22.04 tools: python: "3.11" + apt_packages: - default-libmysqlclient-dev - build-essential + +python: + install: + - requirements: doc/requirements.txt + diff --git a/doc/conf.py b/doc/conf.py index 3e919822..e06003ff 100644 --- a/doc/conf.py +++ b/doc/conf.py @@ -49,8 +49,8 @@ master_doc = "index" # General information about the project. -project = "MySQLdb" -copyright = "2012, Andy Dustman" +project = "mysqlclient" +copyright = "2023, Inada Naoki" # The version info for the project you're documenting, acts as replacement for # |version| and |release|, also used in various other places throughout the @@ -100,7 +100,7 @@ # The theme to use for HTML and HTML Help pages. See the documentation for # a list of builtin themes. -html_theme = "default" +html_theme = "sphinx_rtd_theme" # Theme options are theme-specific and customize the look and feel of a theme # further. For a list of options available for each theme, see the diff --git a/doc/requirements.txt b/doc/requirements.txt new file mode 100644 index 00000000..8d45d0b6 --- /dev/null +++ b/doc/requirements.txt @@ -0,0 +1,2 @@ +sphinx~=7.2 +sphinx-rtd-theme~=1.3.0 From 3805b28abc24cc985ffe7c8a05dd4bd6530aefe8 Mon Sep 17 00:00:00 2001 From: Alex Schmitz Date: Wed, 15 Nov 2023 04:51:10 -0600 Subject: [PATCH 15/19] docs: Improve portability of brew prefix (#667) homebrew's prefix can vary - with this minor change, the pkgconfig path should work in more user environments. --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 9c65ed7e..451ce799 100644 --- a/README.md +++ b/README.md @@ -59,7 +59,7 @@ If you don't want to install MySQL server, you can use mysql-client instead: ```bash $ # Assume you are activating Python 3 venv $ brew install mysql-client pkg-config -$ export PKG_CONFIG_PATH="/opt/homebrew/opt/mysql-client/lib/pkgconfig" +$ export PKG_CONFIG_PATH="$(brew --prefix)/opt/mysql-client/lib/pkgconfig" $ pip install mysqlclient ``` From f82dac326f2344e306fa3885d425cabe33f502b4 Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Tue, 28 Nov 2023 16:55:13 +0900 Subject: [PATCH 16/19] chore(deps): update dependency sphinx-rtd-theme to v2 (#671) --- doc/requirements.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/requirements.txt b/doc/requirements.txt index 8d45d0b6..01406623 100644 --- a/doc/requirements.txt +++ b/doc/requirements.txt @@ -1,2 +1,2 @@ sphinx~=7.2 -sphinx-rtd-theme~=1.3.0 +sphinx-rtd-theme~=2.0.0 From 16017b73546522bc83787e8daf2fd43f37385bc4 Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Thu, 7 Dec 2023 17:02:29 +0900 Subject: [PATCH 17/19] chore(deps): update actions/setup-python action to v5 (#674) --- .github/workflows/tests.yaml | 4 ++-- .github/workflows/windows.yaml | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/tests.yaml b/.github/workflows/tests.yaml index 2ca99a3f..f6a13fd2 100644 --- a/.github/workflows/tests.yaml +++ b/.github/workflows/tests.yaml @@ -38,7 +38,7 @@ jobs: - uses: actions/checkout@v4 - name: Set up Python ${{ matrix.python-version }} - uses: actions/setup-python@v4 + uses: actions/setup-python@v5 with: python-version: ${{ matrix.python-version }} cache: "pip" @@ -81,7 +81,7 @@ jobs: - uses: actions/checkout@v4 - name: Set up Python - uses: actions/setup-python@v4 + uses: actions/setup-python@v5 with: # Django 3.2.9+ supports Python 3.10 # https://docs.djangoproject.com/ja/3.2/releases/3.2/ diff --git a/.github/workflows/windows.yaml b/.github/workflows/windows.yaml index 661b7793..59ef8f21 100644 --- a/.github/workflows/windows.yaml +++ b/.github/workflows/windows.yaml @@ -57,7 +57,7 @@ jobs: EOF cat site.cfg - - uses: actions/setup-python@v4 + - uses: actions/setup-python@v5 - name: Install cibuildwheel run: python -m pip install cibuildwheel==2.12.3 - name: Build wheels From 6831bc2f34271e518758b2bce6414e6df2809461 Mon Sep 17 00:00:00 2001 From: Inada Naoki Date: Fri, 8 Dec 2023 21:36:57 +0900 Subject: [PATCH 18/19] win: update mariadb connector/c to 3.3.8 (#676) --- .github/workflows/windows.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/windows.yaml b/.github/workflows/windows.yaml index 59ef8f21..afbfd4c8 100644 --- a/.github/workflows/windows.yaml +++ b/.github/workflows/windows.yaml @@ -10,7 +10,7 @@ jobs: build: runs-on: windows-latest env: - CONNECTOR_VERSION: "3.3.4" + CONNECTOR_VERSION: "3.3.8" steps: - name: Cache Connector @@ -59,7 +59,7 @@ jobs: - uses: actions/setup-python@v5 - name: Install cibuildwheel - run: python -m pip install cibuildwheel==2.12.3 + run: python -m pip install cibuildwheel - name: Build wheels working-directory: mysqlclient env: From d82d0fd1e7e22bd03bdf417122302307d28ce946 Mon Sep 17 00:00:00 2001 From: Inada Naoki Date: Wed, 13 Dec 2023 22:23:33 +0900 Subject: [PATCH 19/19] Release v2.2.1 (#679) --- HISTORY.rst | 13 +++++++++++++ src/MySQLdb/release.py | 4 ++-- 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/HISTORY.rst b/HISTORY.rst index 377ce83b..99ff66cd 100644 --- a/HISTORY.rst +++ b/HISTORY.rst @@ -1,3 +1,16 @@ +====================== + What's new in 2.2.1 +====================== + +Release: 2023-12-13 + +* ``Connection.ping()`` avoid using ``MYSQL_OPT_RECONNECT`` option until + ``reconnect=True`` is specified. MySQL 8.0.33 start showing warning + when the option is used. (#664) +* Windows: Update MariaDB Connector/C to 3.3.8. (#665) +* Windows: Build wheels for Python 3.12 (#644) + + ====================== What's new in 2.2.0 ====================== diff --git a/src/MySQLdb/release.py b/src/MySQLdb/release.py index 273a297d..c5281a5a 100644 --- a/src/MySQLdb/release.py +++ b/src/MySQLdb/release.py @@ -1,3 +1,3 @@ __author__ = "Inada Naoki " -__version__ = "2.2.0" -version_info = (2, 2, 0, "final", 0) +__version__ = "2.2.1" +version_info = (2, 2, 1, "final", 0)