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

fix connection arguments mysql driver compatability #551

Conversation

betanummeric
Copy link
Member

@betanummeric betanummeric commented May 16, 2023

bugfix for #546, relates to #116

what arguments are supported in what drivers

  • pymysql has deprecated the db argument in 1.0.0 (2021), but it will probably still work for some time. I'm not sure since when pymysql supports the database argument, but at least since 0.7.11, which we test.
  • mysql-python (MySQLdb) only seems to support db. The project was last changed in 2014 so we could discuss if we want to support it. The current issue is about this old driver, see Possible recurrence of issue #151 following latest release of community.mysql? #546 (comment).
  • The successor of mysql-python, mysqlclient, also deprecated the db argument in 2.1.0 (2021), like pymysql.

The same way, passwd is deprecated in favor of password.

proposed fix

Check the mysql driver version to determine what argument to use. Use db and passwd until it's deprecated, then database and password.

@codecov
Copy link

codecov bot commented May 16, 2023

Codecov Report

Merging #551 (3b63c60) into main (b03c9aa) will decrease coverage by 3.08%.
The diff coverage is 6.25%.

@@            Coverage Diff             @@
##             main     #551      +/-   ##
==========================================
- Coverage   77.12%   74.04%   -3.08%     
==========================================
  Files          28       18      -10     
  Lines        2365     2254     -111     
  Branches      557      560       +3     
==========================================
- Hits         1824     1669     -155     
- Misses        383      413      +30     
- Partials      158      172      +14     
Flag Coverage Δ
integration 73.46% <0.00%> (-0.46%) ⬇️
sanity ?
units ?

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
plugins/module_utils/mysql.py 56.66% <6.25%> (-9.38%) ⬇️

... and 18 files with indirect coverage changes

Copy link
Collaborator

@Andersson007 Andersson007 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@betanummeric thanks for the PR!

plugins/module_utils/mysql.py Show resolved Hide resolved
@betanummeric betanummeric marked this pull request as ready for review May 17, 2023 11:16
Copy link
Collaborator

@Andersson007 Andersson007 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@betanummeric looks great, thank you!

@Andersson007 Andersson007 merged commit 7f7b2f7 into ansible-collections:main May 18, 2023
laurent-indermuehle pushed a commit to laurent-indermuehle/community.mysql that referenced this pull request Oct 3, 2023
…ons#551)

* only use the "database" connection argument with driver versions where "db" is deprecated/removed

* connection arguments: fix KeyError

* connection arguments: fix KeyError

* connection arguments: use 'passwd' instead of 'password' with older drivers

* add changelog fragment

* refactoring: use "get_connector_name" in "mysql_connect"

---------

Co-authored-by: Felix Hamme <felix.hamme@ionos.com>
laurent-indermuehle pushed a commit to laurent-indermuehle/community.mysql that referenced this pull request Oct 3, 2023
…ons#551)

* only use the "database" connection argument with driver versions where "db" is deprecated/removed

* connection arguments: fix KeyError

* connection arguments: fix KeyError

* connection arguments: use 'passwd' instead of 'password' with older drivers

* add changelog fragment

* refactoring: use "get_connector_name" in "mysql_connect"

---------

Co-authored-by: Felix Hamme <felix.hamme@ionos.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants