Final bugfixes for the database

This commit is contained in:
Saifeddine ALOUI 2023-04-10 11:14:10 +02:00
parent 364c5e0e28
commit f8ed24684a
2 changed files with 4 additions and 4 deletions

6
app.py
View File

@ -282,7 +282,7 @@ GPT4All:Welcome! I'm here to assist you with anything you need. What can I do fo
data = request.get_json()
discussion_id = data["id"]
title = data["title"]
Discussion.rename(self.db_path, discussion_id, title)
self.db.rename(self.db_path, discussion_id, title)
return "renamed successfully"
def restore_discussion(self, full_message):
@ -314,7 +314,7 @@ GPT4All:Welcome! I'm here to assist you with anything you need. What can I do fo
def delete_discussion(self):
data = request.get_json()
discussion_id = data["id"]
self.current_discussion = Discussion(discussion_id, self.db_path)
self.current_discussion = Discussion(discussion_id, self.db)
self.current_discussion.delete_discussion()
self.current_discussion = None
return jsonify({})
@ -337,7 +337,7 @@ GPT4All:Welcome! I'm here to assist you with anything you need. What can I do fo
def new_discussion(self):
title = request.args.get("title")
self.current_discussion = self.db.create_discussion(self.db_path, title)
self.current_discussion = self.db.create_discussion(title)
# Get the current timestamp
timestamp = datetime.now().strftime("%Y-%m-%d %H:%M:%S")

2
db.py
View File

@ -185,7 +185,7 @@ class Discussion:
new_content (str): The nex message content
"""
self.discussions_db.update(
f"UPDATE message SET content = {new_content} WHERE id = {message_id}"
f"UPDATE message SET content = ? WHERE id = ?",(new_content,message_id)
)