add filters to db
This commit is contained in:
15
lib/db.py
15
lib/db.py
@@ -46,7 +46,7 @@ def importdb(file,importdb,table):
|
||||
|
||||
def createnwview(file):
|
||||
with sqlite3.connect(file) as connection:
|
||||
cmd_create_nw_table = f"""CREATE VIEW "Nordwest-SCHWEIZ" AS SELECT * FROM jobs as b
|
||||
cmd_create_nw_table = f"""CREATE VIEW IF NOT EXISTS "Nordwest-SCHWEIZ" AS SELECT * FROM jobs as b
|
||||
WHERE EXISTS
|
||||
(SELECT GDENAME FROM Cantons as w
|
||||
where w.GDEKT = 'ZH' AND
|
||||
@@ -62,6 +62,19 @@ def createnwview(file):
|
||||
cursor = connection.cursor()
|
||||
cursor.execute(cmd_create_nw_table)
|
||||
print("db connection",connection.total_changes)
|
||||
createFilterTable(file)
|
||||
|
||||
def createFilterTable(file):
|
||||
with sqlite3.connect(file) as connection:
|
||||
cmd_create_filter_table = f"""CREATE TABLE IF NOT EXISTS filters(cmd TEXT);"""
|
||||
cursor = connection.cursor()
|
||||
cursor.execute(cmd_create_filter_table)
|
||||
print("db connection:",connection.total_changes)
|
||||
def addFineFilter(file,table,filterstr):
|
||||
with sqlite3.connect(file) as connection:
|
||||
cmd = f"""INSERT INTO {table}(cmd) VALUES(?);"""
|
||||
cursor = connection.cursor()
|
||||
cursor.execute(cmd,(filterstr,))
|
||||
|
||||
def writedb(jobs):
|
||||
with sqlite3.connect("../db/sqlite3.db") as connection:
|
||||
|
||||
Reference in New Issue
Block a user