add filters to db

This commit is contained in:
2024-06-18 09:58:54 +02:00
parent e5185c2f25
commit 5644c43a61
2 changed files with 15 additions and 3 deletions

View File

@@ -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: