mirror of
https://github.com/ansible-collections/community.mysql.git
synced 2025-08-04 05:04:23 -07:00
only use the "database" connection argument with driver versions where "db" is deprecated/removed
This commit is contained in:
parent
b03c9aac57
commit
be61c65b05
1 changed files with 8 additions and 0 deletions
|
@ -143,9 +143,17 @@ def mysql_connect(module, login_user=None, login_password=None, config_file='',
|
|||
|
||||
if _mysql_cursor_param == 'cursor':
|
||||
# In case of PyMySQL driver:
|
||||
if mysql_driver.version_info[0] < 1:
|
||||
# for PyMySQL < 1.0.0, use 'db' instead of 'database'
|
||||
config['db'] = config['database']
|
||||
del config['database']
|
||||
db_connection = mysql_driver.connect(autocommit=autocommit, **config)
|
||||
else:
|
||||
# In case of MySQLdb driver
|
||||
if mysql_driver.version_info[0] < 2 or mysql_driver.version_info[1] < 1:
|
||||
# for MySQLdb < 2.1.0, use 'db' instead of 'database'
|
||||
config['db'] = config['database']
|
||||
del config['database']
|
||||
db_connection = mysql_driver.connect(**config)
|
||||
if autocommit:
|
||||
db_connection.autocommit(True)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue