Skip to content

#138: Implement real PostgreSQL API and db_client abstraction#170

Open
Vishnu-K-Menon wants to merge 1 commit into
saayam-for-all:devfrom
Vishnu-K-Menon:PR-138-dev
Open

#138: Implement real PostgreSQL API and db_client abstraction#170
Vishnu-K-Menon wants to merge 1 commit into
saayam-for-all:devfrom
Vishnu-K-Menon:PR-138-dev

Conversation

@Vishnu-K-Menon

Copy link
Copy Markdown

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant