|
@ -9,7 +9,7 @@ from ee.core.logging import Log |
|
|
class EEMysql(): |
|
|
class EEMysql(): |
|
|
"""Method for MySQL connection""" |
|
|
"""Method for MySQL connection""" |
|
|
|
|
|
|
|
|
def execute(self, statement): |
|
|
def execute(self, statement, errormsg=''): |
|
|
config = configparser.RawConfigParser() |
|
|
config = configparser.RawConfigParser() |
|
|
cnfpath = expanduser("~")+"/.my.cnf" |
|
|
cnfpath = expanduser("~")+"/.my.cnf" |
|
|
if [cnfpath] == config.read(cnfpath): |
|
|
if [cnfpath] == config.read(cnfpath): |
|
@ -30,9 +30,16 @@ class EEMysql(): |
|
|
user=user, passwd=passwd) |
|
|
user=user, passwd=passwd) |
|
|
cur = conn.cursor() |
|
|
cur = conn.cursor() |
|
|
except Exception as e: |
|
|
except Exception as e: |
|
|
Log.error(self, 'Unable to connect to database: ') |
|
|
if errormsg: |
|
|
Log.debug(self, "{0}".format(e)) |
|
|
Log.debug(self, '{0}' |
|
|
sys.exit(1) |
|
|
.format(e)) |
|
|
|
|
|
Log.error(self, '{0}' |
|
|
|
|
|
.format(errormsg)) |
|
|
|
|
|
else: |
|
|
|
|
|
Log.debug(self, '{0}' |
|
|
|
|
|
.format(e)) |
|
|
|
|
|
Log.error(self, 'Unable to connect to database: {0}' |
|
|
|
|
|
.format(e)) |
|
|
|
|
|
|
|
|
try: |
|
|
try: |
|
|
cur.execute(statement) |
|
|
cur.execute(statement) |
|
|