Skip to content

Commit

Permalink
change deprecated parameter pw to password
Browse files Browse the repository at this point in the history
  • Loading branch information
ziegenberg committed Jun 1, 2021
1 parent 71b2742 commit cbbfd14
Showing 1 changed file with 18 additions and 1 deletion.
19 changes: 18 additions & 1 deletion plugins/module_utils/mysql.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,24 @@ 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:
Expand Down

0 comments on commit cbbfd14

Please sign in to comment.