This commit is contained in:
WorldTeacher
2024-07-30 16:10:02 +02:00
parent 27ec7c296a
commit c3ff3e93ee
8 changed files with 59 additions and 22 deletions

View File

@@ -27,7 +27,6 @@ class ReportThread(QThread):
path = db.db_path
day = QDate.currentDate().addDays(-self.days).toString("yyyy-MM-dd")
query = f"""SELECT * FROM loans WHERE loan_date >= '{day}';"""
print(query)
colnames = ["UserId", "Title", "Action", "Datum"]
table = PrettyTable(colnames)
table.align[colnames[0]] = "l"
@@ -57,9 +56,12 @@ class ReportThread(QThread):
)
# # print(table)
# # wruitng the table to a file
if self.format == "csv":
with open("report.csv", "w", encoding="utf-8") as f:
f.write(table.get_csv_string())
if self.format == "tsv":
table = table.get_csv_string()
tsv_table = table.replace(",", "\t")
# write the file
with open("report.tsv", "w", encoding="utf-8") as f:
f.write(tsv_table)
else:
with open("report.txt", "w", encoding="utf-8") as f:
f.write(str(table))

View File

@@ -14,7 +14,7 @@ def stringToDate(date: str) -> QtCore.QDate:
if not date:
return ""
if isinstance(date, QtCore.QDate):
return date.toString("yyyy-MM-dd")
return date
else:
datedata = date.split("-")
day = datedata[2]