Passed
Push — dev ( 836244...247d11 )
by Stephan
01:23 queued 11s
created

data.datasets.database   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 21
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 15
dl 0
loc 21
rs 10
c 0
b 0
f 0
wmc 3

1 Function

Rating   Name   Duplication   Size   Complexity  
A setup() 0 6 3
1
import functools
2
3
from egon.data import db
4
from egon.data.datasets import Dataset
5
6
7
def setup():
8
    """ Initialize the local database used for data processing. """
9
    engine = db.engine()
10
    with engine.connect().execution_options(autocommit=True) as connection:
11
        for extension in ["hstore", "postgis", "postgis_raster", "pgrouting"]:
12
            connection.execute(f"CREATE EXTENSION IF NOT EXISTS {extension}")
13
14
15
Setup = functools.partial(
16
    Dataset,
17
    name="Database Setup",
18
    version="0.0.0",
19
    dependencies=[],
20
    tasks=setup,
21
)
22