Merge pull request #8101 from elpaso/bugfix-various-dbmanager-query-time-rows

[db-manager] Fix some unreported issues in the SQL dialog
This commit is contained in:
Alessandro Pasotti 2018-10-04 08:26:52 +02:00 committed by GitHub
commit bfe2413019
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 5 additions and 7 deletions

View File

@ -172,8 +172,6 @@ class DBConnector(object):
raise ConnectionError(e)
except self.execution_error_types() as e:
# do the rollback to avoid a "current transaction aborted, commands ignored" errors
self._rollback()
raise DbError(e)
def _get_cursor_columns(self, c):

View File

@ -192,9 +192,7 @@ class SqlResultModel(BaseTableModel):
t = QTime()
t.start()
c = self.db._execute(None, str(sql))
self._secs = t.elapsed() / 1000.0
del t
c = self.db._execute(None, sql)
self._affectedRows = 0
data = []
@ -205,7 +203,7 @@ class SqlResultModel(BaseTableModel):
try:
if len(header) > 0:
data = self.db._fetchall(c)
self._affectedRows = c.rowcount
self._affectedRows = len(data)
except DbError:
# nothing to fetch!
data = []
@ -216,7 +214,9 @@ class SqlResultModel(BaseTableModel):
# commit before closing the cursor to make sure that the changes are stored
self.db._commit()
c.close()
self._secs = t.elapsed() / 1000.0
del c
del t
def secs(self):
return self._secs

View File

@ -260,7 +260,7 @@ class DlgSqlLayerWindow(QWidget, Ui_Dialog):
# set the new model
model = self.db.sqlResultModel(sql, self)
self.viewResult.setModel(model)
self.lblResult.setText(self.tr("{0} rows, {1:.1f} seconds").format(model.affectedRows(), model.secs()))
self.lblResult.setText(self.tr("{0} rows, {1:.3f} seconds").format(model.affectedRows(), model.secs()))
cols = self.viewResult.model().columnNames()
for col in cols:
quotedCols.append(self.db.connector.quoteId(col))