Skip to content
Snippets Groups Projects
Commit 13f28950 authored by morkolai's avatar morkolai
Browse files

#68 Commiter til db der det er nødvendig

parent 6e612912
No related branches found
No related tags found
1 merge request!43#68 Kodebok-oppdatering gjennom GUI og lagre databaseendringer
......@@ -92,7 +92,7 @@ class CodeBookTableModel(QSqlTableModel):
when a value is changed by the view.
The last row is used by the view to insert a new database record,
therefore, only column 'word' (Primary key) is editable in this row.
therefore, only column 'Word' (Primary key) is editable in this row.
All columns except 'Code' are editable.
This class initializes by connecting to database and selecting table.
......
......@@ -144,6 +144,7 @@ class Database:
"""Update Timestamp in LastUpdated to current time."""
stmt = "UPDATE LastUpdated SET Timestamp = ?"
self.conn.execute(stmt, (str(datetime.now()),))
self.conn.commit()
def get_categories(self):
"""
......@@ -230,6 +231,8 @@ class Database:
self.conn.execute(stmt, (codes.pop(), words[i][0]))
# Updates LastUpdated with current time
self.update_last_updated()
# Save changes in db
self.conn.commit()
print("Code in CodeBook updated")
......@@ -329,3 +332,4 @@ class Database:
# Insert code to the param word in db
stmt = "UPDATE CodeBook SET Code = ? WHERE Word = ?"
self.conn.execute(stmt, (code, word))
self.conn.commit()
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment