navapbc / template-application-flask

Apache License 2.0
7 stars 3 forks source link

Change DBClient setup to make multiple clients possible #152

Closed chouinar closed 1 year ago

chouinar commented 1 year ago

Ticket

https://github.com/navapbc/template-application-flask/issues/151

Changes

Modified DBClient to instead take in a DBEngine class which handles setup and connection verification.

Modified the flask_db code to allow for specifying which DBClient to fetch a session from, but defaulting to just have one.

Context for reviewers

On my project, we're soon going to need two DB clients, one for a Postgres DB, and one for an Oracle DB. This makes doing that possible.

Note that in doing this I noticed a few additional things we might want to consider, although I've left them out of this PR to keep it focused:

As there might be some discussion still, I haven't updated all the docs, especially anything regarding the engine. Will do that if this solution looks to be solid

Testing

make test all tests pass - added and moved a few based on the changes

chouinar commented 1 year ago

@lorenyu - let me know if this looks right, and I'll tidy up the comments and docs a bit more