Jean-Frédéric has uploaded a new change for review. ( 
https://gerrit.wikimedia.org/r/390895 )

Change subject: Replace database connection library MysqlDB with PyMySQL
......................................................................

Replace database connection library MysqlDB with PyMySQL

`MySQL-python` is a Python interface to MySQL that had not
been udpated in years. It also needs MySql installed locally,
typically resulting when trying to run locally with:
```
ImportError: libmysqlclient.so.18: cannot open shared object file: No such file 
or directory
```

`PyMySQL` is a pure-Python MySQL client library,
designed as a a drop-in replacement for `MySQLdb`.

See https://github.com/PyMySQL/PyMySQL

Change-Id: Iea3dfb6d71c196aceddb321b599b62bd6b5bec4c
---
M erfgoedbot/database_connection.py
M requirements.txt
M setup.cfg
M tests/test_database_connection.py
4 files changed, 8 insertions(+), 8 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/labs/tools/heritage 
refs/changes/95/390895/1

diff --git a/erfgoedbot/database_connection.py 
b/erfgoedbot/database_connection.py
index 1438e8a..be69e30 100644
--- a/erfgoedbot/database_connection.py
+++ b/erfgoedbot/database_connection.py
@@ -2,7 +2,7 @@
 
 import os
 
-import MySQLdb
+import pymysql
 import yaml
 
 from pywikibot import config as pywikibot_config
@@ -43,7 +43,7 @@
     db_config = get_monuments_database_config()
     username = db_config.get('username', pywikibot_config.db_username)
     password = db_config.get('password', pywikibot_config.db_password)
-    conn = MySQLdb.connect(
+    conn = pymysql.connect(
         host=db_config['server'], db=db_config['db_name'],
         user=username, passwd=password,
         use_unicode=True, charset='utf8')
@@ -55,7 +55,7 @@
 def connect_to_commons_database():
     """Connect to the commons mysql database."""
     db_config = get_commons_database_config()
-    conn = MySQLdb.connect(
+    conn = pymysql.connect(
         host=db_config['server'], db=db_config['db_name'],
         user=pywikibot_config.db_username, passwd=pywikibot_config.db_password,
         use_unicode=True, charset='latin1')
diff --git a/requirements.txt b/requirements.txt
index b698dc0..918e3d1 100644
--- a/requirements.txt
+++ b/requirements.txt
@@ -1,5 +1,5 @@
 future
 pywikibot==3.0.20170403
-MySQL-python
+PyMySQL==0.7.11
 requests
 PyYAML
diff --git a/setup.cfg b/setup.cfg
index 6e52f56..fb416c4 100644
--- a/setup.cfg
+++ b/setup.cfg
@@ -7,7 +7,7 @@
 
 [isort]
 known_first_party = erfgoedbot
-known_third_party = mock,requests,MySQLdb,yaml
+known_third_party = mock,pymysql,requests,yaml
 known_pywikibot = pywikibot
 multi_line_output = 3
 sections = FUTURE,STDLIB,THIRDPARTY,PYWIKIBOT,FIRSTPARTY,LOCALFOLDER
diff --git a/tests/test_database_connection.py 
b/tests/test_database_connection.py
index 3e556cf..45bf24b 100644
--- a/tests/test_database_connection.py
+++ b/tests/test_database_connection.py
@@ -4,7 +4,7 @@
 import unittest
 
 import mock
-from MySQLdb.connections import Connection
+from pymysql.connections import Connection
 
 from erfgoedbot import database_connection
 
@@ -50,7 +50,7 @@
         self.mock_database_config = patcher.start()
         self.addCleanup(patcher.stop)
         self.mock_connection = mock.Mock(spec=Connection)
-        patcher = mock.patch('erfgoedbot.database_connection.MySQLdb.connect')
+        patcher = mock.patch('erfgoedbot.database_connection.pymysql.connect')
         self.mock_connect = patcher.start()
         self.mock_connect.return_value = self.mock_connection
         self.addCleanup(patcher.stop)
@@ -97,7 +97,7 @@
         }
         self.addCleanup(patcher.stop)
         self.mock_connection = mock.Mock(spec=Connection)
-        patcher = mock.patch('erfgoedbot.database_connection.MySQLdb.connect')
+        patcher = mock.patch('erfgoedbot.database_connection.pymysql.connect')
         self.mock_connect = patcher.start()
         self.mock_connect.return_value = self.mock_connection
         self.addCleanup(patcher.stop)

-- 
To view, visit https://gerrit.wikimedia.org/r/390895
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: Iea3dfb6d71c196aceddb321b599b62bd6b5bec4c
Gerrit-PatchSet: 1
Gerrit-Project: labs/tools/heritage
Gerrit-Branch: master
Gerrit-Owner: Jean-Frédéric <[email protected]>

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to