[Feature] Added the docs_response, documents, responses tables and sync with codebase. #114
+591
−7
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
✅ Database Sync & Feature Integration
I’ve implemented the following tables and related methods to ensure they are fully in sync with the rest of the codebase:
📦 Tables Implemented:
docs_responsedocumentsresponsesFollowing this ER diagram:
🛠️ Core Functions:
Database & Table Setup
create_connection()create_table(conn)create_prompts_table(conn)create_response_table(conn)create_document_table(conn)create_docs_response_table(conn)create_all_tables(conn)User Management
insert_user(conn, username, email, type)update_user_loggedin(conn, email, loggedin)update_user_email_verified(conn, email, email_verified)get_user(conn, email)Prompt Management
save_prompt(conn, prompt_type, prompt_value)get_prompt(conn, prompt_type)get_all_prompts(conn)Response Management
insert_response(conn, answer, question, id_user=None)get_response(conn, response_id)get_responses_by_user(conn, user_id)update_response(conn, response_id, answer=None, question=None)delete_response(conn, response_id)Document Management
insert_document(conn, source, metadata=None)get_document(conn, document_id)get_document_by_source(conn, source)get_all_documents(conn)update_document(conn, document_id, source=None, metadata=None)delete_document(conn, document_id)Linking Docs & Responses
link_document_response(conn, id_response, id_document)unlink_document_response(conn, id_response, id_document)get_documents_for_response(conn, response_id)get_responses_for_document(conn, document_id)get_all_document_response_links(conn)get_all_responses_with_documents(conn)Migration
migrate_text_file_to_database(conn, responses_file="responses.txt")📄 Text-to-DB Migration
responses.txtfile.🎬 Demo of the fix:
Watch here