Store last multiline query
When loading, the last multiline query used will be available. Also, refactored the part to execute multiline queries in a separate function.
This commit is contained in:
parent
bf13fe0c4a
commit
cd5c2845e1
@ -94,10 +94,10 @@ class relForm(QtWidgets.QMainWindow):
|
|||||||
compatibility.set_utf8_text(self.ui.txtResult, itm[0])
|
compatibility.set_utf8_text(self.ui.txtResult, itm[0])
|
||||||
compatibility.set_utf8_text(self.ui.txtQuery, itm[1])
|
compatibility.set_utf8_text(self.ui.txtQuery, itm[1])
|
||||||
|
|
||||||
def execute(self):
|
def _run_multiline(self):
|
||||||
'''Executes the query'''
|
|
||||||
if self.multiline:
|
|
||||||
query = compatibility.get_py_str(self.ui.txtMultiQuery.toPlainText())
|
query = compatibility.get_py_str(self.ui.txtMultiQuery.toPlainText())
|
||||||
|
self.settings.setValue('multiline/query', query)
|
||||||
|
|
||||||
queries = query.split('\n')
|
queries = query.split('\n')
|
||||||
|
|
||||||
for query in queries:
|
for query in queries:
|
||||||
@ -116,15 +116,19 @@ class relForm(QtWidgets.QMainWindow):
|
|||||||
expr = parser.parse(query)
|
expr = parser.parse(query)
|
||||||
result = eval(expr, self.relations)
|
result = eval(expr, self.relations)
|
||||||
self.relations[relname] = result
|
self.relations[relname] = result
|
||||||
self.updateRelations() # update the list
|
|
||||||
self.selectedRelation = result
|
|
||||||
self.showRelation(self.selectedRelation)
|
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
print(str(e))
|
print(str(e))
|
||||||
QtWidgets.QMessageBox.information(None, QtWidgets.QApplication.translate("Form", "Error"), u"%s\n%s" %
|
QtWidgets.QMessageBox.information(None, QtWidgets.QApplication.translate("Form", "Error"), u"%s\n%s" %
|
||||||
(QtWidgets.QApplication.translate("Form", "Check your query!"), str(e)))
|
(QtWidgets.QApplication.translate("Form", "Check your query!"), str(e)))
|
||||||
return
|
break
|
||||||
|
self.updateRelations() # update the list
|
||||||
|
self.selectedRelation = result
|
||||||
|
self.showRelation(self.selectedRelation)
|
||||||
|
|
||||||
|
def execute(self):
|
||||||
|
'''Executes the query'''
|
||||||
|
if self.multiline:
|
||||||
|
return self._run_multiline()
|
||||||
|
|
||||||
#Single line query
|
#Single line query
|
||||||
query = compatibility.get_py_str(self.ui.txtQuery.text())
|
query = compatibility.get_py_str(self.ui.txtQuery.text())
|
||||||
@ -277,6 +281,7 @@ class relForm(QtWidgets.QMainWindow):
|
|||||||
def restore_settings(self):
|
def restore_settings(self):
|
||||||
# self.settings.value('session_name','default').toString()
|
# self.settings.value('session_name','default').toString()
|
||||||
self.setMultiline(self.settings.value('multiline','false')=='true')
|
self.setMultiline(self.settings.value('multiline','false')=='true')
|
||||||
|
self.ui.txtMultiQuery.setPlainText(self.settings.value('multiline/query',''))
|
||||||
|
|
||||||
def showSurvey(self):
|
def showSurvey(self):
|
||||||
if self.Survey == None:
|
if self.Survey == None:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user