Re-unite query execution functions
For multi-line and single-line. After the change with the assignment they are basically the same and there was no longer need to have them separate in two functions.
This commit is contained in:
parent
03ae3e0bab
commit
474bea6ff5
@ -168,45 +168,36 @@ class relForm(QtWidgets.QMainWindow):
|
|||||||
itm = item.text()
|
itm = item.text()
|
||||||
self.ui.txtQuery.setText(itm)
|
self.ui.txtQuery.setText(itm)
|
||||||
|
|
||||||
def _run_multiline(self):
|
|
||||||
query = self.ui.txtMultiQuery.toPlainText()
|
|
||||||
self.settings.setValue('multiline/query', query)
|
|
||||||
|
|
||||||
try:
|
|
||||||
result = self.user_interface.multi_execute(query)
|
|
||||||
except Exception as e:
|
|
||||||
return self.error(e)
|
|
||||||
finally:
|
|
||||||
self.updateRelations()
|
|
||||||
self.selectedRelation = result
|
|
||||||
self.showRelation(self.selectedRelation)
|
|
||||||
|
|
||||||
def execute(self):
|
def execute(self):
|
||||||
|
|
||||||
|
# Show the 'Processing' frame
|
||||||
self.ui.stackedWidget.setCurrentIndex(2)
|
self.ui.stackedWidget.setCurrentIndex(2)
|
||||||
QtCore.QCoreApplication.processEvents()
|
QtCore.QCoreApplication.processEvents()
|
||||||
|
|
||||||
try:
|
try:
|
||||||
'''Executes the query'''
|
'''Executes the query'''
|
||||||
if self.multiline:
|
if self.multiline:
|
||||||
return self._run_multiline()
|
query = self.ui.txtMultiQuery.toPlainText()
|
||||||
|
self.settings.setValue('multiline/query', query)
|
||||||
# Single line query
|
else:
|
||||||
res_rel,query = self.user_interface.split_query(self.ui.txtQuery.text())
|
query = self.ui.txtQuery.text()
|
||||||
|
|
||||||
try:
|
try:
|
||||||
self.selectedRelation = self.user_interface.execute(query, res_rel)
|
self.selectedRelation = self.user_interface.multi_execute(query)
|
||||||
self.updateRelations() # update the list
|
|
||||||
self.showRelation(self.selectedRelation)
|
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
return self.error(e)
|
return self.error(e)
|
||||||
|
finally:
|
||||||
|
self.updateRelations() # update the list
|
||||||
|
self.showRelation(self.selectedRelation)
|
||||||
|
|
||||||
# Adds to history
|
if not self.multiline:
|
||||||
hitem = QtWidgets.QListWidgetItem(None, 0)
|
# Adds to history
|
||||||
hitem.setText(self.ui.txtQuery.text())
|
hitem = QtWidgets.QListWidgetItem(None, 0)
|
||||||
self.ui.lstHistory.addItem(hitem)
|
hitem.setText(query)
|
||||||
self.ui.lstHistory.setCurrentItem(hitem)
|
self.ui.lstHistory.addItem(hitem)
|
||||||
|
self.ui.lstHistory.setCurrentItem(hitem)
|
||||||
finally:
|
finally:
|
||||||
|
# Restore the normal frame
|
||||||
self.setMultiline(self.multiline)
|
self.setMultiline(self.multiline)
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user