BookOps-CAT / NightShift

Copy cataloging bot
MIT License
7 stars 1 forks source link

Datastore conn init #2

Closed klinga closed 2 years ago

klinga commented 2 years ago
  1. This update provides basic connectivity to postgres via datastore.DataAccessLayer. I added a context manager (session_scope) to add a convenient method to call and exit a db session. I made assumption that db settings will be pulled from env variables as it is for local and Travis tests.
  2. Also created a new module datastore_transactions.py to house any methods to communicate with the db. At the moment there are only two basic operations - I will add more later when I have a better idea what is needed.
  3. Made some changes to tables: opted for internal/independent identifier for the Resource table (previously it had two primary keys: sierraId and libraryId), but that somewhat complicated relations between the tables (double foreign keys?). Instead I added a unique constraint for combination of sierraId and libraryId that should accomplish the same thing.
  4. Do I need to worry about character encoding in Postgres? Collation? I had some issues in MySQL, but it looks Postgres is handling it better.

It took me a while to figure out correct Travis settings to install Posgresql 13 (their default is 9.6 which I thought may not be a good idea). Made some silly but frustrating mistakes along the way...

klinga commented 2 years ago

Thanks @mwbenowitz! I considered all of your suggestions and updated accordingly this PR. Will merge it now.