mirror of
https://github.com/sqlmapproject/sqlmap.git
synced 2024-11-22 09:36:35 +03:00
Fixes #1189
This commit is contained in:
parent
02fb5058c2
commit
9bd41ed99d
|
@ -29,6 +29,7 @@ from lib.core.datatype import AttribDict
|
|||
from lib.core.defaults import _defaults
|
||||
from lib.core.enums import CONTENT_STATUS
|
||||
from lib.core.enums import PART_RUN_CONTENT_TYPES
|
||||
from lib.core.exception import SqlmapConnectionException
|
||||
from lib.core.log import LOGGER_HANDLER
|
||||
from lib.core.optiondict import optDict
|
||||
from lib.core.subprocessng import Popen
|
||||
|
@ -66,8 +67,11 @@ class Database(object):
|
|||
logger.debug("REST-JSON API %s connected to IPC database" % who)
|
||||
|
||||
def disconnect(self):
|
||||
self.cursor.close()
|
||||
self.connection.close()
|
||||
if self.cursor:
|
||||
self.cursor.close()
|
||||
|
||||
if self.connection:
|
||||
self.connection.close()
|
||||
|
||||
def commit(self):
|
||||
self.connection.commit()
|
||||
|
@ -252,8 +256,11 @@ class LogRecorder(logging.StreamHandler):
|
|||
|
||||
def setRestAPILog():
|
||||
if hasattr(conf, "api"):
|
||||
conf.database_cursor = Database(conf.database)
|
||||
conf.database_cursor.connect("client")
|
||||
try:
|
||||
conf.database_cursor = Database(conf.database)
|
||||
conf.database_cursor.connect("client")
|
||||
except sqlite3.OperationalError, ex:
|
||||
raise SqlmapConnectionException, "%s ('%s')" % (ex, conf.database)
|
||||
|
||||
# Set a logging handler that writes log messages to a IPC database
|
||||
logger.removeHandler(LOGGER_HANDLER)
|
||||
|
|
Loading…
Reference in New Issue
Block a user