Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added an optional DB connector file to standardize the connections from the app to PGO. #51

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

ahron1
Copy link

@ahron1 ahron1 commented Jun 15, 2021

The purpose of the optional DB Connector is to have a standard interface for the rest of the app to communicate with PGO. This will make it easy to reflect any changes in the return type of PGO (e.g. when it moved from returning tuples to maps). Or to replace another tool with PGO, or vice versa. So the app calls functions defined in a "helper" file. And the helper file communicates with PGO via the connector. So in case of any changes with PGO, only this connector file needs to be updated, and not every pgo:query call.

@tsloughter
Copy link
Collaborator

I'm not sure about this, esp not having having the pgo_ prefix to "namespace" it.

@ahron1
Copy link
Author

ahron1 commented Dec 8, 2021

Yes, this is the part the application uses to interface with pgo. Basically the idea is that from the PoV of the application, any PostgreSQL interface is a drop-in replacement. Just pass the query and params.

It is this file that the dev team has to tweak if they switch to another connector. The core app code can thus remain untouched.

@abxy
Copy link

abxy commented Dec 9, 2021

@ahron1: Wouldn't it make more sense to keep the db_connector module in your own application? That way you are free to alter the implementation to suit your needs, including switching the underlying database driver. By putting it in pgo you're effectively handing control of the interface to someone else, in a way it's equivalent to targeting the pgo API directly.

@ahron1
Copy link
Author

ahron1 commented Dec 12, 2021

It is like saying to the user - you don't have to be locked-in if you try out pgo. Because if the entire codebase uses pgo calls, it is a sort of lock-in, in the sense that switching to an alternative will need multiple changes.

You are right that ideally it should be in the application. But many people just call pgo directly. So this is also a way of ensuring good coding practice by users.

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.

3 participants