Skip to content

Updating file postgres_connector.py: All functions refactored to use try_query function.#282

Merged
cheezyrock merged 5 commits intomainfrom
jmuller_working
Feb 26, 2026
Merged

Updating file postgres_connector.py: All functions refactored to use try_query function.#282
cheezyrock merged 5 commits intomainfrom
jmuller_working

Conversation

@hollowtree11
Copy link
Collaborator

Fixes #267, #279, #281

A try_query function was created that is responsible for the database connection and error handling. Its parameters include the sql statement, parameters, and a fetch variable that will be "all" or "one", depending on the data being collected.

Within the function, DictCursor is used to convert rows into Python dictionaries. The function executes the sql statement, fetches the correct data, handles errors accordingly, and returns the result to the calling function. Combining these functionalities into a single function eliminates many lines of codes and keeps the database connection from opening and closing unnecessarily.

@cheezyrock cheezyrock merged commit 49fdaab into main Feb 26, 2026
4 of 5 checks passed
@github-project-automation github-project-automation bot moved this from Backlog to Done in dads - issue tracking Feb 26, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Development

Successfully merging this pull request may close these issues.

Database Connection Re-use

2 participants