Skip to content

Commit

Permalink
🐛 use helper read_sql function instead of pd.read_sql
Browse files Browse the repository at this point in the history
  • Loading branch information
Marigold committed Apr 11, 2024
1 parent 9cdbaad commit cbe31fe
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
4 changes: 2 additions & 2 deletions apps/staging_sync/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
from etl import grapher_model as gm
from etl.config import GRAPHER_USER_ID
from etl.datadiff import _dict_diff
from etl.db import Engine, get_engine
from etl.db import Engine, get_engine, read_sql

from .admin_api import AdminAPI

Expand Down Expand Up @@ -404,7 +404,7 @@ def _modified_chart_ids_by_admin(session: Session) -> Set[int]:
select id from charts where publishedAt is not null
)
"""
return set(pd.read_sql(q, session.bind).chartId.tolist())
return set(read_sql(q, session.bind).chartId.tolist()) # type: ignore


def _get_git_branch_creation_date(branch_name: str) -> dt.datetime:
Expand Down
7 changes: 4 additions & 3 deletions etl/grapher_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@

from etl import config, paths
from etl.config import GRAPHER_USER_ID
from etl.db import read_sql

log = structlog.get_logger()

Expand Down Expand Up @@ -717,9 +718,9 @@ def load_sources(
) t
order by t.id
"""
sources = pd.read_sql(
sources = read_sql(
q,
session.bind,
session.bind, # type: ignore
params={
"datasetId": dataset_id,
# NOTE: query doesn't work with empty list so we use a dummy value
Expand All @@ -737,7 +738,7 @@ def load_sources(
)
sources.datasetId = sources.datasetId.fillna(dataset_id).astype(int)

return [cls(**d) for d in sources.to_dict(orient="records") if cls.validate(d)]
return [cls(**d) for d in sources.to_dict(orient="records") if cls.validate(d)] # type: ignore


class SuggestedChartRevisions(SQLModel, table=True):
Expand Down

0 comments on commit cbe31fe

Please sign in to comment.