Skip to content

Commit

Permalink
Cleaning code with whitespaces
Browse files Browse the repository at this point in the history
  • Loading branch information
SGA-pranamika-pandey committed Jan 23, 2024
1 parent 12bdad4 commit 18252c0
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions databaseconnect.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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")
Expand All @@ -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
Expand Down

0 comments on commit 18252c0

Please sign in to comment.