Skip to content

Commit

Permalink
fix linting and error handling
Browse files Browse the repository at this point in the history
  • Loading branch information
maurerle committed Oct 22, 2024
1 parent 7b36a77 commit 33bded0
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 19 deletions.
2 changes: 1 addition & 1 deletion crawler/axxteq.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
import pandas as pd
from sqlalchemy import create_engine, text

from config import db_uri
from common.config import db_uri

log = logging.getLogger(__name__)

Expand Down
2 changes: 1 addition & 1 deletion crawler/ecmwf.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
from shapely.geometry import Point
from sqlalchemy import create_engine, text

from config import db_uri
from common.config import db_uri

"""
Note that only requests with no more that 1000 items at a time are valid.
Expand Down
2 changes: 1 addition & 1 deletion crawler/enet.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
import pandas as pd
from sqlalchemy import create_engine, text

from config import db_uri
from common.config import db_uri

log = logging.getLogger("MaStR")
log.setLevel(logging.INFO)
Expand Down
2 changes: 1 addition & 1 deletion crawler/regelleistung.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
import sqlalchemy
from sqlalchemy import create_engine, text

from .config import db_uri
from common.config import db_uri

log = logging.getLogger("regelleistung")
log.setLevel(logging.INFO)
Expand Down
27 changes: 12 additions & 15 deletions crawler/vea_industrial_load_profiles.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
"schema_name": "vea-industrial-load-profiles",
"data_date": "2016-01-01",
"data_source": "https://zenodo.org/records/13910298",
"license": "Creative Commons Attribution 4.0 International Public License",
"license": "CC-BY-4.0",
"description": """The data consists of 5359 one-year quarterhourly industrial load profiles (2016, leap year, 35136 values).
Each describes the electricity consumption of one industrial commercial site in Germany used for official accounting.
Local electricity generation was excluded from the data as far as it could be discovered (no guarantee of completeness).
Expand Down Expand Up @@ -194,11 +194,7 @@ def create_schema():
engine = create_engine(db_uri)

with engine.begin() as conn:
query = text(
"""
CREATE SCHEMA IF NOT EXISTS "vea-industrial-load-profiles"
"""
)
query = text('CREATE SCHEMA IF NOT EXISTS "vea-industrial-load-profiles"')
conn.execute(query)

log.info("Succesfully created schema")
Expand All @@ -215,17 +211,18 @@ def convert_to_hypertable(relation_name: str):
log.info("Trying to create hypertable")

engine = create_engine(db_uri)

with engine.begin() as conn:
query = text(
f"SELECT public.create_hypertable('{relation_name}', 'timestamp', if_not_exists => TRUE, migrate_data => TRUE);"
)
conn.execute(query)

log.info("Succesfully create hypertable")
try:
with engine.begin() as conn:
query = text(
f"SELECT public.create_hypertable('{relation_name}', 'timestamp', if_not_exists => TRUE, migrate_data => TRUE);"
)
conn.execute(query)
log.info("Succesfully create hypertable")
except Exception as e:
log.error(f"could not create hypertable: {e}")


def main():
def main(db_uri):
# request zip archive
response = request_zip_archive()

Expand Down

0 comments on commit 33bded0

Please sign in to comment.