|
6 | 6 | # This script creates a SQLite database to store user information. |
7 | 7 | # It includes functions to create a connection to the database, create a table for users, |
8 | 8 | # 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 """ |
10 | 11 | conn = None |
11 | 12 | try: |
12 | | - conn = sqlite3.connect('users.db') |
| 13 | + conn = sqlite3.connect(db_file) |
13 | 14 | except sqlite3.Error as e: |
14 | 15 | print(e) |
15 | 16 | return conn |
@@ -136,7 +137,6 @@ def create_feedback_table(conn): |
136 | 137 | reason TEXT, |
137 | 138 | timestamp TEXT |
138 | 139 | );''' |
139 | | - # ==================== ADDITIONAL FUNCTIONS FOR OTHER TABLES ==================== |
140 | 140 | conn.cursor().execute(sql) |
141 | 141 | conn.commit() |
142 | 142 | except sqlite3.Error as e: |
@@ -441,6 +441,7 @@ def create_all_tables(conn): |
441 | 441 | """Create all tables in the database""" |
442 | 442 | create_table(conn) # users table |
443 | 443 | create_prompts_table(conn) |
| 444 | + create_feedback_table(conn) |
444 | 445 | create_response_table(conn) |
445 | 446 | create_document_table(conn) |
446 | 447 | create_docs_response_table(conn) |
@@ -573,6 +574,3 @@ def migrate_text_file_to_database(conn, responses_file="responses.txt"): |
573 | 574 |
|
574 | 575 | return migrated_count |
575 | 576 |
|
576 | | -if __name__ == "__main__": |
577 | | - conn = create_connection() |
578 | | - insert_user( conn, "dev", "[email protected]", "admin") |
0 commit comments