Improve search db

This commit is contained in:
James Jennett-Wheeler 2025-06-26 14:59:29 +01:00
parent 34008046b2
commit 65b03dadb2
2 changed files with 5 additions and 5 deletions

View File

@ -44,6 +44,7 @@ class Application:
if type(application) is Application: if type(application) is Application:
table.add_row([application.reference, application.dateScraped, application.dateDecided, application.decision, application.caseOfficer, application.num_documents, application.description]) table.add_row([application.reference, application.dateScraped, application.dateDecided, application.decision, application.caseOfficer, application.num_documents, application.description])
table.align = "l" table.align = "l"
table.max_width["Description"] = 200
print(table) print(table)
def __init__(self, cursor: Cursor, reference: str): def __init__(self, cursor: Cursor, reference: str):

View File

@ -1,16 +1,15 @@
from application import Application from application import Application
import sqlite3 import sqlite3
import sys
where_clause = ' '.join(sys.argv[1:])
with sqlite3.connect("./database.db") as connection: with sqlite3.connect("./database.db") as connection:
cursor = connection.cursor() cursor = connection.cursor()
applications = [] applications = []
print("This week's Application decisions:") cursor.execute(f"SELECT reference FROM applications {where_clause} ORDER BY dateScraped DESC, dateDecided DESC")
cursor.execute("SELECT reference FROM applications WHERE dateScraped >= '2025-06-23' ORDER BY dateDecided DESC")
# print("Chris' Applications:")
# cursor.execute("SELECT reference FROM applications WHERE caseOfficer = 'Christopher Masters' ORDER BY dateDecided DESC")
for (application_ref,) in cursor.fetchall(): for (application_ref,) in cursor.fetchall():
applications.append(Application(cursor, application_ref)) applications.append(Application(cursor, application_ref))