Skip to content

Commit

Permalink
update with some lazy env config
Browse files Browse the repository at this point in the history
  • Loading branch information
bh2smith committed Oct 13, 2024
1 parent 8d33c31 commit 1593068
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 4 deletions.
7 changes: 6 additions & 1 deletion .env.sample
Original file line number Diff line number Diff line change
@@ -1,2 +1,7 @@
DB_URL=postgresql://postgres:postgres@localhost:5432/postgres
DUNE_API_KEY=
DB_URL=postgresql://postgres:postgres@localhost:5432/postgres

QUERY_ID=
POLL_FREQUENCY=10
# Optional.
QUERY_ENGINE=medium
12 changes: 9 additions & 3 deletions src/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,14 @@
from src.types import DUNE_TO_PG

load_dotenv()
DUNE_API_KEY = os.getenv("DUNE_API_KEY")
DB_URL = os.getenv("DB_URL")
TABLE_NAME = "dune_data"

# TODO(bh2smith): parse config file for most of the following stuff
QUERY_ID = int(os.getenv("QUERY_ID"))
POLL_FREQUENCY=int(os.getenv("POLL_FREQUENCY"))
QUERY_ENGINE = os.getenv("QUERY_ENGINE")
TABLE_NAME = f"dune_data_{QUERY_ID}"


def reformat_varbinary_columns(df, varbinary_columns):
Expand All @@ -20,8 +26,8 @@ def reformat_varbinary_columns(df, varbinary_columns):

def fetch_dune_data():
result = (
DuneClient.from_env()
.run_query(query=QueryBase(4132129), ping_frequency=10)
DuneClient(DUNE_API_KEY, performance=QUERY_ENGINE)
.run_query(query=QueryBase(QUERY_ID), ping_frequency=POLL_FREQUENCY)
.result
)

Expand Down

0 comments on commit 1593068

Please sign in to comment.