From 18252c07bd8ea381cedc1e4f31777eba608306d0 Mon Sep 17 00:00:00 2001 From: SGA-pranamika-pandey Date: Tue, 23 Jan 2024 22:32:26 +0000 Subject: [PATCH] Cleaning code with whitespaces --- databaseconnect.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/databaseconnect.py b/databaseconnect.py index ab29684..988aa4d 100644 --- a/databaseconnect.py +++ b/databaseconnect.py @@ -49,7 +49,7 @@ def connection_to_database() -> object: @logger_config.logger # setup database -def setup_database(): +def setup_database() -> object: """ Setup database with chat table, question table, statement table and directions table @@ -77,7 +77,7 @@ def setup_database(): # add classified sentences to database def add_to_database(classification: str, subject: str, root: str, verb: str, sentence: str) -> None: """ - Adds the classified sentences to database, if not already exists. + Adds the classified sentence to database, if not already exists. Args: classification (str): The classification of statement: a chat, question or statement @@ -97,6 +97,7 @@ def add_to_database(classification: str, subject: str, root: str, verb: str, sen "INSERT INTO chat_table(root_word,verb,sentence) VALUES (%s, %s, %s)", (str(root), str(verb), sentence,) ) db.commit() + # If classification of user input is question ('Q'), checks the question table if it's already present elif classification == "Q": cursor.execute("SELECT sentence FROM question_table") @@ -112,7 +113,9 @@ def add_to_database(classification: str, subject: str, root: str, verb: str, sen "INSERT INTO question_table(subject,root_word,verb,sentence) VALUES (%s,%s,%s,%s)", (str(subject), str(root),str(verb),H,) ) db.commit() + else: + # Adds to statement table otherwise cursor.execute("SELECT sentence FROM statement_table") result = cursor.fetchall() exist = 0