#138: Implement real PostgreSQL API and db_client abstraction#170
Open
Vishnu-K-Menon wants to merge 1 commit into
Open
#138: Implement real PostgreSQL API and db_client abstraction#170Vishnu-K-Menon wants to merge 1 commit into
Vishnu-K-Menon wants to merge 1 commit into
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
This PR completes Phase 1 and Phase 2 of Issue #138, transitioning beneficiary_trend_analysis.py from using fake CSV mock data to querying the real PostgreSQL database.
Note: The initial fake-data removal was already present in the latest pull, so these updates were built on top of those existing changes.
Changes Made (Phase 1 & 2)
Region Update: Updated the SQL queries and table schemas to correctly target the Ireland region.
Architecture Compliance: Noticed src/utils/db_client.py was missing from the repository. Created this foundational database abstraction layer to comply with the strict CONTRIBUTING.md guidelines for future vector store migrations.
Empty Data Handling: Added checks to ensure the Lambda returns empty lists [] rather than crashing if the database tables have no rows.
Error Handling: Wrapped the DB connections and query functions in try/except blocks. Ensured connections close gracefully in a finally block.
Local Testing: Verified the script locally without AWS credentials. The try/except block successfully caught the missing database connection and gracefully returned a 500 status code with the expected JSON error message, preventing a hard crash.