mirror of
https://github.com/saltstack/salt.git
synced 2025-04-17 10:10:20 +00:00
Merge pull request #26803 from twangboy/fix_26754
Added check for PyMySQL if MySQLdb import fails
This commit is contained in:
commit
c892be3255
1 changed files with 13 additions and 1 deletions
|
@ -49,13 +49,25 @@ import salt.utils
|
|||
|
||||
# Import third party libs
|
||||
try:
|
||||
# Try to import MySQLdb
|
||||
import MySQLdb
|
||||
import MySQLdb.cursors
|
||||
import MySQLdb.converters
|
||||
from MySQLdb.constants import FIELD_TYPE, FLAG
|
||||
HAS_MYSQLDB = True
|
||||
except ImportError:
|
||||
HAS_MYSQLDB = False
|
||||
try:
|
||||
# MySQLdb import failed, try to import PyMySQL
|
||||
import pymysql
|
||||
pymysql.install_as_MySQLdb()
|
||||
import MySQLdb
|
||||
import MySQLdb.cursors
|
||||
import MySQLdb.converters
|
||||
from MySQLdb.constants import FIELD_TYPE, FLAG
|
||||
HAS_MYSQLDB = True
|
||||
except ImportError:
|
||||
# No MySQL Connector installed, return False
|
||||
HAS_MYSQLDB = False
|
||||
|
||||
log = logging.getLogger(__name__)
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue