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

Commit

Permalink
update pyproject; cli and settings to create working connection
Browse files Browse the repository at this point in the history
  • Loading branch information
aplybeah committed Jun 25, 2024
1 parent 1d5bce6 commit 2f9d957
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 10 deletions.
2 changes: 0 additions & 2 deletions analytics/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -152,8 +152,6 @@ sprint-db-data-import:
@echo "=> Importing project data to the database"
@echo "====================================================="
$(POETRY) analytics export db_export \
--owner $(ORG) \
--project $(SPRINT_PROJECT) \
--sprint-file $(SPRINT_FILE) \
--issue-file $(ISSUE_FILE)

Expand Down
25 changes: 24 additions & 1 deletion analytics/poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions analytics/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ python = "^3.11"
slack-sdk = "^3.23.0"
typer = { extras = ["all"], version = "^0.9.0" }
sqlalchemy = "^2.0.30"
psycopg = ">=3.0.7"

[tool.poetry.group.dev.dependencies]
black = "^23.7.0"
Expand Down
2 changes: 1 addition & 1 deletion analytics/settings.toml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
POSTGRES_NAME = "app"
POSTGRES_HOST = "0.0.0.0"
POSTGRES_HOST = "grants-analytics-db"
POSTGRES_USER = "app"
POSTGRES_PORT = 5432
10 changes: 4 additions & 6 deletions analytics/src/analytics/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -151,24 +151,22 @@ def test_connection() -> None:

@export_app.command(name="db_export")
def export_json_to_database(
# dataset: BaseDataset, # got RuntimeError: Type not yet supported with this defined here
sprint_file: Annotated[str, SPRINT_FILE_ARG],
issue_file: Annotated[str, ISSUE_FILE_ARG],
) -> None:
"""Export JSON data to the database."""
# Get the database engine and establish a connection
engine = db.get_db()
connection = engine.connect()

# get data and load from JSON
task_data = DeliverableTasks.load_from_json_files(
deliverable_data = DeliverableTasks.load_from_json_files(
sprint_file=sprint_file,
issue_file=issue_file,
)

BaseDataset.to_sql(
output_table=task_data,
engine=connection,
deliverable_data.to_sql(
output_table="github_project_data",
engine=engine,
replace_table=True,
) # replace_table=True is the default

Expand Down

0 comments on commit 2f9d957

Please sign in to comment.