mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-04-24 11:21:25 -07:00
Migrate from MySQLdb to PyMySQL (#40123)
* Migrate from MySQLdb to PyMySQL * Deduplicate driver loading and failure message * Explain requirements * Apply requirements docs change to proxysql too * Add changelog
This commit is contained in:
parent
205693a3f9
commit
d34cf93f1a
20 changed files with 92 additions and 179 deletions
|
@ -67,7 +67,8 @@ requirements:
|
|||
- mysql (command line binary)
|
||||
- mysqldump (command line binary)
|
||||
notes:
|
||||
- Requires the python-mysqldb package on the remote host, as well as mysql and mysqldump binaries.
|
||||
- Requires the PyMySQL (Python 2.7 and Python 3.X) or MySQL-python (Python 2.X) package on the remote host,
|
||||
as well as mysql and mysqldump binaries.
|
||||
- This module is B(not idempotent) when I(state) is C(import), and will import the dump file each time if run more than once.
|
||||
extends_documentation_fragment: mysql
|
||||
'''
|
||||
|
@ -107,16 +108,9 @@ import pipes
|
|||
import subprocess
|
||||
import traceback
|
||||
|
||||
try:
|
||||
import MySQLdb
|
||||
except ImportError:
|
||||
mysqldb_found = False
|
||||
else:
|
||||
mysqldb_found = True
|
||||
|
||||
from ansible.module_utils.basic import AnsibleModule
|
||||
from ansible.module_utils.database import mysql_quote_identifier
|
||||
from ansible.module_utils.mysql import mysql_connect, mysqldb_found
|
||||
from ansible.module_utils.mysql import mysql_connect, mysql_driver, mysql_driver_fail_msg
|
||||
from ansible.module_utils._text import to_native
|
||||
|
||||
|
||||
|
@ -279,8 +273,8 @@ def main():
|
|||
supports_check_mode=True
|
||||
)
|
||||
|
||||
if not mysqldb_found:
|
||||
module.fail_json(msg="The MySQL-python module is required.")
|
||||
if mysql_driver is None:
|
||||
module.fail_json(msg=mysql_driver_fail_msg)
|
||||
|
||||
db = module.params["name"]
|
||||
encoding = module.params["encoding"]
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue