diff --git a/commands.sql b/commands.sql new file mode 100644 index 0000000..5200618 --- /dev/null +++ b/commands.sql @@ -0,0 +1,3 @@ +INSERT INTO "main"."todo"("ID","TODO","CREATION_DATE","DUE_DATE","PRIO","IMP") VALUES (NULL,'example task 1','1711408035','1711408095',100,0); +INSERT INTO "main"."todo"("ID","TODO","CREATION_DATE","DUE_DATE","PRIO","IMP") VALUES (NULL,'example task 2','1711408035','1711408095',100,0); +INSERT INTO "main"."todo"("ID","TODO","CREATION_DATE","DUE_DATE","PRIO","IMP") VALUES (NULL,'example task 3','1711408035','1711408095',100,0); diff --git a/create_db.sh b/create_db.sh new file mode 100755 index 0000000..4e20d6a --- /dev/null +++ b/create_db.sh @@ -0,0 +1,2 @@ +sqlite3 todo.db ".read create_db.sql" +echo created database diff --git a/create_db.sql b/create_db.sql new file mode 100644 index 0000000..588a557 --- /dev/null +++ b/create_db.sql @@ -0,0 +1,10 @@ +CREATE TABLE "todo" ( + "ID" INTEGER UNIQUE, + "TODO" TEXT NOT NULL, + "CREATION_DATE" INTEGER NOT NULL, + "DUE_DATE" INTEGER NOT NULL, + "PRIO" INTEGER NOT NULL, +"IMP" INTEGER NOT NULL, + + PRIMARY KEY("ID" AUTOINCREMENT) +); diff --git a/db_to_csv.sh b/db_to_csv.sh new file mode 100755 index 0000000..cf9fdd5 --- /dev/null +++ b/db_to_csv.sh @@ -0,0 +1,2 @@ +rm -v input.csv +sqlite3 todo.db 'SELECT * FROM todo;' -csv> db.csv diff --git a/dump.txt b/dump.txt new file mode 100644 index 0000000..4e41967 --- /dev/null +++ b/dump.txt @@ -0,0 +1,3 @@ +example task 1 +example task 2 +example task 3 diff --git a/fresh_db.sh b/fresh_db.sh new file mode 100755 index 0000000..9421208 --- /dev/null +++ b/fresh_db.sh @@ -0,0 +1,30 @@ +sqlite3 todo.db "DROP TABLE todo;" +sqlite3 todo.db ".read create_db.sql" +echo created database +#!/bin/bash +rm commands.sql -v +# File to read +file="dump.txt" + +# Counter for line number +line_number=1 + +# Read each line of the file +while IFS= read -r line; do + # Store the line in a variable + variable_name="line_$line_number" + declare "$variable_name"="$line" + + # Increment the line number counter + ((line_number++)) +done < "$file" + +# Print the variables to verify +for ((i=1; i> commands.sql +done +echo converted $file to sql statements +sqlite3 todo.db ".read commands.sql" +echo inserted sql statements to database diff --git a/main.py b/main.py new file mode 100644 index 0000000..43677ca --- /dev/null +++ b/main.py @@ -0,0 +1,68 @@ +import sqlite3 +from datetime import datetime +import time +import tkinter as tk + +con = sqlite3.connect("todo.db") +cur = con.cursor() + + +def add_item(): + item = entry.get() + if item: + listbox.insert(tk.END, item) + entry.delete(0, tk.END) # deletes input + + +def remove_item(): + selected_index = listbox.curselection() + if selected_index: + listbox.delete(selected_index) + + +def update_list(): + cur_time = (datetime.now() - datetime(1970, 1, 1)).total_seconds() + time.timezone + + total_time = [] + remaining_time = [] + importance = [] + + res = cur.execute("SELECT * FROM todo").fetchall() + for i, tmp1 in enumerate(res): + total_time.append(res[i][3] - res[i][2]) + remaining_time.append(res[i][3] - cur_time) + importance.append(total_time[i] / remaining_time[i] * res[i][4]) + if int(importance[i]) == 0: + importance[i] = 1 + print("UPDATE todo SET IMP = %s WHERE ID = %s" % (int(importance[i]), i + 1)) + cur.execute("UPDATE todo SET IMP = %s WHERE ID = %s" % (int(importance[i]), i + 1)) + print(i) + listbox.insert(tk.END, res[i][0]) + con.commit() + + +# Create the main window +root = tk.Tk() +root.title("Ion-Todo-Planner") + +# Create a listbox to display the items +listbox = tk.Listbox(root, width=100) +listbox.pack(padx=5, pady=5) + + +# Create an entry for adding items +entry = tk.Entry(root, width=50) +entry.pack(padx=10, pady=5) + +# Create buttons to add and remove items +add_button = tk.Button(root, text="Add", command=add_item) +add_button.pack(side=tk.LEFT, padx=5, pady=5) + +remove_button = tk.Button(root, text="Remove", command=remove_item) +remove_button.pack(side=tk.LEFT, padx=5, pady=5) + +update_button = tk.Button(root, text="Update", command=update_list) +update_button.pack(padx=5, pady=5) + +# Run the Tkinter event loop +root.mainloop() diff --git a/sample.py b/sample.py new file mode 100644 index 0000000..68aa93d --- /dev/null +++ b/sample.py @@ -0,0 +1,16 @@ +# This is a sample Python script. + +# Press Shift+F10 to execute it or replace it with your code. +# Press Double Shift to search everywhere for classes, files, tool windows, actions, and settings. + + +def print_hi(name): + # Use a breakpoint in the code line below to debug your script. + print(f'Hi, {name}') # Press Ctrl+8 to toggle the breakpoint. + + +# Press the green button in the gutter to run the script. +if __name__ == '__main__': + print_hi('PyCharm') + +# See PyCharm help at https://www.jetbrains.com/help/pycharm/ diff --git a/todo.db b/todo.db new file mode 100644 index 0000000..5913516 Binary files /dev/null and b/todo.db differ diff --git a/txt_to_cmd.sh b/txt_to_cmd.sh new file mode 100755 index 0000000..2714da2 --- /dev/null +++ b/txt_to_cmd.sh @@ -0,0 +1,25 @@ +#!/bin/bash +rm commands.sql -v +# File to read +file="dump.txt" + +# Counter for line number +line_number=1 + +# Read each line of the file +while IFS= read -r line; do + # Store the line in a variable + variable_name="line_$line_number" + declare "$variable_name"="$line" + + # Increment the line number counter + ((line_number++)) +done < "$file" + +# Print the variables to verify +for ((i=1; i> commands.sql +done +echo converted $file to sql statements diff --git a/write_cmd_to_db.sh b/write_cmd_to_db.sh new file mode 100755 index 0000000..50a356f --- /dev/null +++ b/write_cmd_to_db.sh @@ -0,0 +1,3 @@ +sqlite3 todo.db ".read commands.sql" +echo inserted sql statements to database +rm commands.sql -v