optimize cmd history

This commit is contained in:
ccppi 2024-06-18 12:52:18 +02:00
parent a6f70d9492
commit 9999a5fd42
2 changed files with 14 additions and 6 deletions

View File

@ -72,9 +72,11 @@ def createFilterTable(file):
print("db connection:",connection.total_changes)
def addFineFilter(file,table,filterstr):
with sqlite3.connect(file) as connection:
cmd = f"""INSERT INTO {table}(cmd) VALUES(?);"""
cmd_createFineFilter = f"""INSERT INTO {table}(cmd) VALUES(?);"""
cmd_checkIfExists = f"""SELECT * FROM {table} WHERE cmd = ?"""
cursor = connection.cursor()
cursor.execute(cmd,(filterstr,))
if cursor.execute(cmd_checkIfExists,(filterstr,)).fetchone() == None:
cursor.execute(cmd_createFineFilter,(filterstr,))
def writedb(jobs):
with sqlite3.connect("../db/sqlite3.db") as connection:

View File

@ -114,6 +114,7 @@ class MainWindow(QMainWindow):
if self.w is None:
self.w = QueryWindow()
self.w.show()
self.w.queryFineFilers()
def filter_canton(self,canton):
if canton != "ALL":
self.cmdCanton = f"""
@ -141,7 +142,8 @@ class MainWindow(QMainWindow):
connectingstring = ' '
print(self.initcmd + self.cmdCanton +connectingstring +self.customcmd + self.cmd)
self.customSQL(self.initcmd+ self.cmdCanton + connectingstring + self.customcmd + self.cmd)
addFineFilter("../db/sqlite3.db","filters",self.customcmd + self.cmd)
if self.customcmd or self.cmd:
addFineFilter("../db/sqlite3.db","filters",self.customcmd + self.cmd)
def cell_clicked(self):
x = self.view.selectionModel().currentIndex().row()
@ -230,9 +232,8 @@ class QueryWindow(QWidget):
self.CShowViews.currentTextChanged.connect(self.setView)
self.CShowFineFilters = QComboBox()
FineFilterItems = self.getFineFilters()
for item in FineFilterItems:
self.CShowFineFilters.addItem(item)
self.queryFineFilers()
self.CShowFineFilters.currentTextChanged.connect(window.EditQuery.setText)
self.PApplyView = QCheckBox()
@ -260,6 +261,11 @@ class QueryWindow(QWidget):
self.EditQuery.setText(window.customcmd)
print("Comboshowview:",self.CShowViews.currentText())
def queryFineFilers(self):
self.CShowFineFilters.clear()
FineFilterItems = self.getFineFilters()
for item in FineFilterItems:
self.CShowFineFilters.addItem(item)
def getFineFilters(self):
item = []
statement = f"""Select cmd FROM filters;"""