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

change deprecated parameter pw and db #177

Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
minor_changes:
- mysql module utils - change deprecated connection parameters ``passwd`` and ``db`` to ``password`` and ``database`` (https://github.com/ansible-collections/community.mysql/pull/177).
38 changes: 36 additions & 2 deletions plugins/module_utils/mysql.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,15 +79,49 @@ def mysql_connect(module, login_user=None, login_password=None, config_file='',
if login_user is not None:
config['user'] = login_user
if login_password is not None:
config['passwd'] = login_password
if mysql_driver.__name__ == "pymysql":
# In case of PyMySQL driver:
version_tuple = (n for n in mysql_driver.__version__.split('.') if n != 'None')
if reduce(lambda x, y: int(x) * 100 + int(y), version_tuple) >= 607:
# pymysql >= 0.6.7
config['password'] = login_password
else:
# NOTE: This check SHOULD be removed as soon as the minimum support version of PyMySQL for this collection reaches pymysql v0.6.7
config['passwd'] = login_password
else:
# In case of MySQLdb driver
version_tuple = (n for n in mysql_driver.__version__.split('.') if n != 'None')
if reduce(lambda x, y: int(x) * 100 + int(y), version_tuple) >= 10308:
# mysqlclient >= 1.3.8
config['password'] = login_password
else:
# NOTE: This check SHOULD be removed as soon as the minimum support version of MySQLdb for this collection reaches mysqlclient v1.3.8
config['passwd'] = login_password
if ssl_cert is not None:
config['ssl']['cert'] = ssl_cert
if ssl_key is not None:
config['ssl']['key'] = ssl_key
if ssl_ca is not None:
config['ssl']['ca'] = ssl_ca
if db is not None:
config['db'] = db
if mysql_driver.__name__ == "pymysql":
# In case of PyMySQL driver:
version_tuple = (n for n in mysql_driver.__version__.split('.') if n != 'None')
if reduce(lambda x, y: int(x) * 100 + int(y), version_tuple) >= 607:
# pymysql >= 0.6.7
config['database'] = db
else:
# NOTE: This check SHOULD be removed as soon as the minimum support version of PyMySQL for this collection reaches pymysql v0.6.7
config['db'] = db
else:
# In case of MySQLdb driver
version_tuple = (n for n in mysql_driver.__version__.split('.') if n != 'None')
if reduce(lambda x, y: int(x) * 100 + int(y), version_tuple) >= 10308:
# mysqlclient >= 1.3.8
config['database'] = login_password
else:
# NOTE: This check SHOULD be removed as soon as the minimum support version of MySQLdb for this collection reaches mysqlclient v1.3.8
config['db'] = db
if connect_timeout is not None:
config['connect_timeout'] = connect_timeout
if check_hostname is not None:
Expand Down