Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Let user set MySQLdb version #793

Closed
wants to merge 3 commits into from
Closed

Let user set MySQLdb version #793

wants to merge 3 commits into from

Conversation

eavictor
Copy link
Contributor

@eavictor eavictor commented May 4, 2019

Add an extra argument for setup MySQLdb version

To methane:

Compatibility issue has been report multiple times.
This patch lets user setup MySQLdb version for preventing new issue about MySQLdb version in future.

Related issues:

#610 Compatibility with Django 2.0
#790 Compatibility with Django 2.2

To others:

This is not the fix for #790 from PyMySQL side

Fix from Django only applies to master branch, see #30380 for detail

Backport to stable/2.2.x branch has been closed, see Django PR#11318 for detail
Please use other MySQL connector or avoid using stable/2.2.x at this time

Usage:

import pymysql
pymysql.install_as_MySQLdb(MySQLdb_version=(1, 4, 2, "final", 0))

eavictor added 3 commits May 4, 2019 23:49
As same type of issues coming up for 2 times.
[Compatibility with Django 2.0](#610)
[Compatibility with Django 2.2](#790)

Let user set MySQLdb version is a better way to prevent same type of
issues keep showing up multiple times.

Default behavior:
```python
>>> import pymysql
>>> pymysql.install_as_MySQLdb()
>>> pymysql.version_info
(1, 3, 12, 'final', 0)
>>>
```

With `MySQLdb_version=(1, 4, 2, "final", 0)` argument passed in:
```python
>>> import pymysql
>>> pymysql.install_as_MySQLdb(MySQLdb_version=(1, 4, 2, "final", 0))
WARNING: Use at your own risk !!
Set MySQLdb version = (1, 4, 2, 'final', 0)
>>> pymysql.version_info
(1, 4, 2, 'final', 0)
>>>
```
Library provide PY2 fails under Python 3.7.3 (Windows platform).
Use print_function to avoid SyntaxError when printing warning message.
change
type(MySQLdb_version) == tuple
to
isinstance(MySQLdb_version, tuple)
@methane methane closed this May 6, 2019
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jul 31, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants