Skip to content

Commit

Permalink
connect to db only when required
Browse files Browse the repository at this point in the history
  • Loading branch information
smnorris committed Aug 15, 2024
1 parent 3655113 commit 644b65a
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions download.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@

LOG_FORMAT = "%(asctime)s:%(levelname)s:%(name)s: %(message)s"
LOG = logging.getLogger(__name__)
DB = create_engine(os.environ.get("DATABASE_URL"))


def configure_logging(verbosity):
Expand Down Expand Up @@ -294,7 +293,8 @@ def download(sources_file, source_alias, dry_run, out_path, verbose, quiet):

# load to postgres, writing everything to the same initial table
LOG.info(f"Writing {source['alias']} to postgres")
df.to_postgis("designations_source", DB, if_exists="append")
db = create_engine(os.environ.get("DATABASE_URL"))
df.to_postgis("designations_source", db, if_exists="append")

# dump to file if out_path specified
if out_path:
Expand Down

0 comments on commit 644b65a

Please sign in to comment.