jenkins-bot has submitted this change and it was merged. (
https://gerrit.wikimedia.org/r/495740 )
Change subject: mysql: drop support for MySQLdb module
......................................................................
mysql: drop support for MySQLdb module
The PyMySql module has been the default since 72f072f0c and is the
prefered python module. Its advantage over MySQLdb is the module is
pure python and does not depend on having the mysql client to be
installed on the host. It is thus easier to install for end users.
Remove left over legacy support of MySQLdb.
Add a note in HISTORY.rst as a hint.
Note that the code is only used by pagegenerators.py
Bug: T89976
Bug: T243154
Change-Id: Iaa295b27269d40ae6f157635044493566ce39b18
---
M HISTORY.rst
M pywikibot/data/mysql.py
2 files changed, 7 insertions(+), 22 deletions(-)
Approvals:
Xqt: Looks good to me, approved
jenkins-bot: Verified
diff --git a/HISTORY.rst b/HISTORY.rst
index c6f2898..a182023 100644
--- a/HISTORY.rst
+++ b/HISTORY.rst
@@ -4,6 +4,8 @@
Current release
---------------
+* pagengenerators.py no more support 'oursql' or 'MySQLdb'. It now
solely
+ support PyMySQL
https://pypi.org/project/PyMySQL/ (T243154, T89976)
* Bugfixes and improvements
* Localisation updates
diff --git a/pywikibot/data/mysql.py b/pywikibot/data/mysql.py
index 980e9c8..15a6ceb 100644
--- a/pywikibot/data/mysql.py
+++ b/pywikibot/data/mysql.py
@@ -9,21 +9,11 @@
import pywikibot
-# Requires PyMySql as first choice or
-# MySQLdb <https://sourceforge.net/projects/mysql-python/>
try:
- import pymysql as mysqldb
+ import pymysql
except ImportError:
- try:
- import MySQLdb as mysqldb # noqa: N813
- except ImportError:
- raise ImportError('No supported MySQL library installed. '
- 'Please install PyMySQL.')
- else:
- pywikibot.warning("PyMySQL not found. It'll fallback "
- 'on the deprecated library MySQLdb.')
-else:
- mysqldb.install_as_MySQLdb()
+ raise ImportError('MySQL python module not found. Please install PyMySQL.')
+
from pywikibot import config2 as config
from pywikibot.tools import deprecated_args, UnicodeType
@@ -67,7 +57,7 @@
else:
credentials = {'read_default_file': config.db_connect_file}
- conn = mysqldb.connect(config.db_hostname,
+ conn = pymysql.connect(config.db_hostname,
db=config.db_name_format.format(dbname),
port=config.db_port,
charset='utf8',
@@ -76,14 +66,7 @@
cursor = conn.cursor()
if verbose:
- try:
- _query = cursor.mogrify(query, params)
- except AttributeError: # if MySQLdb is used.
- # Not exactly the same encoding handling as cursor.execute()
- # Here it is just for the sake of verbose.
- _query = query
- if params is not None:
- _query = query.format(params)
+ _query = cursor.mogrify(query, params)
if not isinstance(_query, UnicodeType):
_query = UnicodeType(_query, encoding='utf-8')
--
To view, visit
https://gerrit.wikimedia.org/r/495740
To unsubscribe, or for help writing mail filters, visit
https://gerrit.wikimedia.org/r/settings
Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-MessageType: merged
Gerrit-Change-Id: Iaa295b27269d40ae6f157635044493566ce39b18
Gerrit-Change-Number: 495740
Gerrit-PatchSet: 4
Gerrit-Owner: Hashar <hashar(a)free.fr>
Gerrit-Reviewer: Hashar <hashar(a)free.fr>
Gerrit-Reviewer: John Vandenberg <jayvdb(a)gmail.com>
Gerrit-Reviewer: Mpaa <mpaa.wiki(a)gmail.com>
Gerrit-Reviewer: Multichill <maarten(a)mdammers.nl>
Gerrit-Reviewer: Xqt <info(a)gno.de>
Gerrit-Reviewer: Zhuyifei1999 <zhuyifei1999(a)gmail.com>
Gerrit-Reviewer: jenkins-bot (75)
Gerrit-CC: Dvorapa <dvorapa(a)seznam.cz>