Skip to content

Commit 39cf5e0

Browse files
committed
remove hardcoded db name and clean test-script
Signed-off-by: lochanpaudel <[email protected]>
1 parent 1cf53cf commit 39cf5e0

File tree

1 file changed

+4
-6
lines changed

1 file changed

+4
-6
lines changed

src/mvt/database.py

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,11 @@
66
# This script creates a SQLite database to store user information.
77
# It includes functions to create a connection to the database, create a table for users,
88
# insert a new user, update user information, and retrieve user data.
9-
def create_connection():
9+
def create_connection(db_file="users.db"):
10+
""" create a database connection to a SQLite database """
1011
conn = None
1112
try:
12-
conn = sqlite3.connect('users.db')
13+
conn = sqlite3.connect(db_file)
1314
except sqlite3.Error as e:
1415
print(e)
1516
return conn
@@ -136,7 +137,6 @@ def create_feedback_table(conn):
136137
reason TEXT,
137138
timestamp TEXT
138139
);'''
139-
# ==================== ADDITIONAL FUNCTIONS FOR OTHER TABLES ====================
140140
conn.cursor().execute(sql)
141141
conn.commit()
142142
except sqlite3.Error as e:
@@ -441,6 +441,7 @@ def create_all_tables(conn):
441441
"""Create all tables in the database"""
442442
create_table(conn) # users table
443443
create_prompts_table(conn)
444+
create_feedback_table(conn)
444445
create_response_table(conn)
445446
create_document_table(conn)
446447
create_docs_response_table(conn)
@@ -573,6 +574,3 @@ def migrate_text_file_to_database(conn, responses_file="responses.txt"):
573574

574575
return migrated_count
575576

576-
if __name__ == "__main__":
577-
conn = create_connection()
578-
insert_user(conn,"dev","[email protected]","admin")

0 commit comments

Comments
 (0)