optimize cmd history
This commit is contained in:
parent
a6f70d9492
commit
9999a5fd42
@ -72,9 +72,11 @@ def createFilterTable(file):
|
|||||||
print("db connection:",connection.total_changes)
|
print("db connection:",connection.total_changes)
|
||||||
def addFineFilter(file,table,filterstr):
|
def addFineFilter(file,table,filterstr):
|
||||||
with sqlite3.connect(file) as connection:
|
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 = connection.cursor()
|
||||||
cursor.execute(cmd,(filterstr,))
|
if cursor.execute(cmd_checkIfExists,(filterstr,)).fetchone() == None:
|
||||||
|
cursor.execute(cmd_createFineFilter,(filterstr,))
|
||||||
|
|
||||||
def writedb(jobs):
|
def writedb(jobs):
|
||||||
with sqlite3.connect("../db/sqlite3.db") as connection:
|
with sqlite3.connect("../db/sqlite3.db") as connection:
|
||||||
|
12
lib/gui.py
12
lib/gui.py
@ -114,6 +114,7 @@ class MainWindow(QMainWindow):
|
|||||||
if self.w is None:
|
if self.w is None:
|
||||||
self.w = QueryWindow()
|
self.w = QueryWindow()
|
||||||
self.w.show()
|
self.w.show()
|
||||||
|
self.w.queryFineFilers()
|
||||||
def filter_canton(self,canton):
|
def filter_canton(self,canton):
|
||||||
if canton != "ALL":
|
if canton != "ALL":
|
||||||
self.cmdCanton = f"""
|
self.cmdCanton = f"""
|
||||||
@ -141,6 +142,7 @@ class MainWindow(QMainWindow):
|
|||||||
connectingstring = ' '
|
connectingstring = ' '
|
||||||
print(self.initcmd + self.cmdCanton +connectingstring +self.customcmd + self.cmd)
|
print(self.initcmd + self.cmdCanton +connectingstring +self.customcmd + self.cmd)
|
||||||
self.customSQL(self.initcmd+ self.cmdCanton + connectingstring + self.customcmd + self.cmd)
|
self.customSQL(self.initcmd+ self.cmdCanton + connectingstring + self.customcmd + self.cmd)
|
||||||
|
if self.customcmd or self.cmd:
|
||||||
addFineFilter("../db/sqlite3.db","filters",self.customcmd + self.cmd)
|
addFineFilter("../db/sqlite3.db","filters",self.customcmd + self.cmd)
|
||||||
|
|
||||||
def cell_clicked(self):
|
def cell_clicked(self):
|
||||||
@ -230,9 +232,8 @@ class QueryWindow(QWidget):
|
|||||||
self.CShowViews.currentTextChanged.connect(self.setView)
|
self.CShowViews.currentTextChanged.connect(self.setView)
|
||||||
|
|
||||||
self.CShowFineFilters = QComboBox()
|
self.CShowFineFilters = QComboBox()
|
||||||
FineFilterItems = self.getFineFilters()
|
|
||||||
for item in FineFilterItems:
|
self.queryFineFilers()
|
||||||
self.CShowFineFilters.addItem(item)
|
|
||||||
self.CShowFineFilters.currentTextChanged.connect(window.EditQuery.setText)
|
self.CShowFineFilters.currentTextChanged.connect(window.EditQuery.setText)
|
||||||
|
|
||||||
self.PApplyView = QCheckBox()
|
self.PApplyView = QCheckBox()
|
||||||
@ -260,6 +261,11 @@ class QueryWindow(QWidget):
|
|||||||
self.EditQuery.setText(window.customcmd)
|
self.EditQuery.setText(window.customcmd)
|
||||||
|
|
||||||
print("Comboshowview:",self.CShowViews.currentText())
|
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):
|
def getFineFilters(self):
|
||||||
item = []
|
item = []
|
||||||
statement = f"""Select cmd FROM filters;"""
|
statement = f"""Select cmd FROM filters;"""
|
||||||
|
Loading…
Reference in New Issue
Block a user