#12821 closed enhancement (fixed)
Add support for pymysql library
Reported by: | Ryan J Ollos | Owned by: | Ryan J Ollos |
---|---|---|---|
Priority: | normal | Milestone: | 1.3.2 |
Component: | database backend | Version: | |
Severity: | normal | Keywords: | mysql |
Cc: | Branch: | ||
Release Notes: |
PyMySQL is the supported MySQL library, with support dropped for MySQL-python. |
||
API Changes: | |||
Internal Changes: |
Attachments (0)
Change History (15)
comment:1 by , 7 years ago
Release Notes: | modified (diff) |
---|
follow-up: 7 comment:2 by , 7 years ago
I omitted something important. Tests pass with the following change:
-
setup.py
diff --git a/setup.py b/setup.py index 633a4d3b3..cd6fa235f 100755
a b facilities. 95 95 extras_require = { 96 96 'genshi': ['Genshi>=0.6'], 97 97 'babel': ['Babel>=0.9.5'], 98 'mysql': [' MySQL-python >= 1.2.2'],98 'mysql': ['PyMySQL'], 99 99 'postgresql': ['psycopg2 >= 2.0'], 100 100 'pygments': ['Pygments>=1.0'], 101 101 'rest': ['docutils>=0.3.9'],
I haven't looked closely if or how we can specify "MySQL-python or PyMySQL" for the installation requirement in setup.py
.
Also, looks like signature of _show_warnings
changed in PyMySQL 0.7.6, and latest package has a strange version string:
>>> import pymysql as MySQLdb >>> MySQLdb.__version__ '0.7.11.None'
Additional changes in [42f422aeb/rjollos.git].
comment:3 by , 7 years ago
how we can specify "MySQL-python or PyMySQL" for the installation requirement in
setup.py
.
According to this (and this) it seems something like this would be needed:
-
setup.py
diff -r 22cef9e62a11 setup.py
a b 41 41 print("Jinja2 is needed by Trac setup, pre-installing") 42 42 # give some context to the warnings we might get when installing Jinja2 43 43 44 try: 45 import pymysql 46 mysql = 'PyMySQL' 47 except ImportError: 48 mysql = 'MySQL-python >= 1.2.2' 49 44 50 45 51 setup( 46 52 name = 'Trac', … … 95 101 extras_require = { 96 102 'genshi': ['Genshi>=0.6'], 97 103 'babel': ['Babel>=0.9.5'], 98 'mysql': [ 'MySQL-python >= 1.2.2'],104 'mysql': [mysql], 99 105 'postgresql': ['psycopg2 >= 2.0'], 100 106 'pygments': ['Pygments>=1.0'], 101 107 'rest': ['docutils>=0.3.9'],
comment:4 by , 7 years ago
It might be good to support mysql+mysqldb://...
for MySQL-python and mysql+pymysql://...
for PyMySQL, like SQLAlchemy.
Another consideration, how about switching to PyMySQL from MySQL-python? The original MySQL-python doesn't support Python 3 but https://github.com/PyMySQL/mysqlclient-python supports Python 3. No new commits since 2014 on https://github.com/farcepest/MySQLdb1.
comment:5 by , 7 years ago
I like the idea of supporting just one MySQL library.
I started to update the compatible distros matrix. pymysql
is available on Ubuntu 16.04. I don't see it in Debian 8.8, and looks like it may still be in unstable. Does anyone think that matters since a user can just pip install
it?
follow-up: 9 comment:6 by , 7 years ago
Proposed additional changes in [4f56ad5b2/jomae.git]. I'd like to add charset
parameter to database connection string for MySQL, to avoid reconnecting when database charset is not matched with client charset.
Yeah, no matters. Even Trac 1.2 on Debian is still sid.
comment:7 by , 7 years ago
Replying to Ryan J Ollos:
Also, looks like signature of
_show_warnings
changed in PyMySQL 0.7.6, and latest package has a strange version string:
Created a pull request for the issue.
comment:8 by , 7 years ago
Release Notes: | modified (diff) |
---|
Latest changes, including comment:6 changes, in log:rjollos.git:t12821_pymysql.1.
Tests pass on OSX with the following versions of pymysql:
- 0.7.11
- 0.6.7
- 0.6
- DONE Update 1.3/TracInstall (1.3/TracInstall@7)
- DONE Update 1.3/TracUpgrade (1.3/TracUpgrade@15)
comment:9 by , 7 years ago
Replying to Jun Omae:
Proposed additional changes in [4f56ad5b2/jomae.git]. I'd like to add
charset
parameter to database connection string for MySQL, to avoid reconnecting when database charset is not matched with client charset.
I might have overlooked an import change. Should the AppVeyor config be modified?:
-
.appveyor.yml
diff --git a/.appveyor.yml b/.appveyor.yml index 34ad19c22..6b9ea0430 100644
a b environment: 21 21 TRAC_TEST_DB_URI: sqlite:test.db 22 22 - SVN_BRANCH: trunk 23 23 PYTHONHOME: C:\Miniconda 24 TRAC_TEST_DB_URI: mysql://tracuser:password@localhost/trac 24 TRAC_TEST_DB_URI: mysql://tracuser:password@localhost/trac?charset=utf8mb4 25 25 - SVN_BRANCH: trunk 26 26 PYTHONHOME: C:\Miniconda-x64 27 27 TRAC_TEST_DB_URI: postgres://tracuser:password@localhost/trac?schema=tractest
comment:10 by , 7 years ago
Release Notes: | modified (diff) |
---|
Committed to trunk in r15965.
- Edited TracDev/ApiChanges/1.3@27
- Edited MySqlDb@76
comment:11 by , 7 years ago
Resolution: | → fixed |
---|---|
Status: | assigned → closed |
Added charset
to MySQL database connection string in r15966.
follow-up: 13 comment:12 by , 7 years ago
I noticed Django recommends mysqlclient on Python 3 at https://docs.djangoproject.com/en/1.11/ref/databases/#mysql-db-api-drivers.
follow-up: 14 comment:13 by , 7 years ago
Replying to Jun Omae:
I noticed Django recommends mysqlclient on Python 3 at https://docs.djangoproject.com/en/1.11/ref/databases/#mysql-db-api-drivers.
It would be interesting to see if mysqlclient serves as a drop-in replacement for MySQLdb, as stated on the Django page. The issue has been raised in gdiscussion:trac-users:ET632_nYAc0.
comment:14 by , 7 years ago
Replying to Ryan J Ollos:
It would be interesting to see if mysqlclient serves as a drop-in replacement for MySQLdb, as stated on the Django page. The issue has been raised in gdiscussion:trac-users:ET632_nYAc0.
⇒ #12952.
comment:15 by , 5 years ago
Release Notes: | modified (diff) |
---|
Proposed changes in [4bacb9a74/rjollos.git].
DONE Add Travis CI and AppVeyor build configurations that use pymysql.