Skip to content
This repository has been archived by the owner on Sep 18, 2024. It is now read-only.

Commit

Permalink
working connection
Browse files Browse the repository at this point in the history
  • Loading branch information
aplybeah committed Jun 6, 2024
1 parent e2c36f0 commit 7768290
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 2 deletions.
17 changes: 16 additions & 1 deletion analytics/src/analytics/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,16 @@

from analytics.datasets.deliverable_tasks import DeliverableTasks
from analytics.datasets.sprint_board import SprintBoard
from analytics.integrations import github, slack
from analytics.integrations import github, slack, db
from analytics.metrics.base import BaseMetric, Unit
from analytics.metrics.burndown import SprintBurndown
from analytics.metrics.burnup import SprintBurnup
from analytics.metrics.percent_complete import DeliverablePercentComplete

import logging
import sqlalchemy
logger = logging.getLogger(__name__)

# fmt: off
# Instantiate typer options with help text for the commands below
SPRINT_FILE_ARG = typer.Option(help="Path to file with exported sprint data")
Expand Down Expand Up @@ -121,6 +125,17 @@ def calculate_sprint_burnup(
output_dir=output_dir,
)

@export_app.command(name="test_connection")
def test_connection(
) -> None:
"""Test function that ensures the DB connection works."""
engine = db.get_db()
# connection method from sqlalchemy
engine.connect()
logger.warning("Connected to postgres db")
print(engine)
print(engine.connect())


@metrics_app.command(name="deliverable_percent_complete")
def calculate_deliverable_percent_complete(
Expand Down
2 changes: 1 addition & 1 deletion analytics/src/analytics/integrations/db.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,5 @@ def get_db() -> Engine:
sqlalchemy.engine.Engine
A SQLAlchemy engine object representing the connection to the database.
"""
# return create_engine( , pool_pre_ping=True)

return create_engine(settings.database_url, pool_pre_ping=True)

0 comments on commit 7768290

Please sign in to comment.