Skip to content
Permalink
Browse files

Try to add cancel support for Oracle databases in dbmanager

  • Loading branch information
pblottiere authored and nyalldawson committed Apr 21, 2018
1 parent b22121a commit d589ba7d7c3e3c210d670d0db7a0f645eaff7b24
@@ -1743,3 +1743,7 @@ def getSqlDictionary(self):
def getQueryBuilderDictionary(self):
from .sql_dictionary import getQueryBuilderDictionary
return getQueryBuilderDictionary()

def cancel(self):
# how to cancel an Oracle query?
pass
@@ -26,7 +26,11 @@

from qgis.PyQt.QtCore import QTime

from ..data_model import TableDataModel, SqlResultModel, BaseTableModel
from ..data_model import (TableDataModel,
SqlResultModel,
SqlResultModelAsync,
SqlResultModelTask,
BaseTableModel)
from ..plugin import DbError


@@ -114,6 +118,36 @@ def fetchMoreData(self, row_start):
self.fetchedFrom = row_start


class ORSqlResultModelTask(SqlResultModelTask):

def __init__(self, db, sql, parent):
super().__init__(db, sql, parent)

def run(self):
try:
self.model = ORSqlResultModel(self.db, self.sql, None)
except BaseError as e:
self.error = e
QgsMessageLog.logMessage(e.msg)
return False

return True

def cancel(self):
self.db.connector.cancel()
SqlResultModelTask.cancel(self)


class ORSqlResultModelAsync(SqlResultModelAsync):

def __init__(self, db, sql, parent):
super().__init__()

self.task = ORSqlResultModelTask(db, sql, parent)
self.task.taskCompleted.connect(self.modelDone)
self.task.taskTerminated.connect(self.modelDone)


class ORSqlResultModel(SqlResultModel):

def __init__(self, db, sql, parent=None):
@@ -192,6 +192,11 @@ def sqlResultModel(self, sql, parent):
from .data_model import ORSqlResultModel
return ORSqlResultModel(self, sql, parent)

def sqlResultModelAsync(self, sql, parent):
from .data_model import ORSqlResultModelAsync

return ORSqlResultModelAsync(self, sql, parent)

def toSqlLayer(self, sql, geomCol, uniqueCol,
layerName=u"QueryLayer", layerType=None,
avoidSelectById=False, filter=""):

0 comments on commit d589ba7

Please sign in to comment.
You can’t perform that action at this time.