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

isolated db in its own module #601

Merged
merged 4 commits into from
May 10, 2020
Merged

Conversation

jmensch1
Copy link
Contributor

@jmensch1 jmensch1 commented May 9, 2020

I'm somewhat confident that this will fix the db connection bug (#550). Of course we won't know for sure until it's live on production. And if it doesn't work, there's some logging code in this PR that we can enable to help find the issue.

The idea here is to isolate the sqlalchemy engine in its own module so that we're not running create_engine on every request. The engine gets configured when the app loads. This is similar to how the redis connection is configured.

  • Up to date with dev branch
  • Branch name follows guidelines
  • All PR Status checks are successful
  • Peer reviewed and approved

Any questions? See the getting started guide

@jmensch1 jmensch1 linked an issue May 9, 2020 that may be closed by this pull request
@jmensch1 jmensch1 added this to the 311-Data - Beta milestone May 9, 2020
@jmensch1 jmensch1 requested a review from sellnat77 May 9, 2020 22:13
from .databaseOrm import Ingest as Request
from utils.database import db


class DataService(object):
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can probably remove this constructor altogether at this point
We can move the table name to a constant in this class and the indv methods can define alternate tables (when and if) we decide to break the db into diff tables

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good call, I removed the constructor. And then updated the services that call the DataService, so it's created without arguments.

As for the table name, turns out it wasn't even being used anywhere in the DataService. So I deleted it for now. If we split up tables we can add it as a constant, so it would be like a default table that can be overridden.

@sellnat77 sellnat77 merged commit 65963ac into dev May 10, 2020
@sellnat77 sellnat77 deleted the 550-BACK-PersistingDBConnections branch May 10, 2020 15:55
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.

Connections to DB are still persisting
2 participants