exposurejapan.py 1.6 KB
Newer Older
Simantini Shinde's avatar
Simantini Shinde committed
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
#!/usr/bin/env python3

# Copyright (C) 2021:
#   Helmholtz-Zentrum Potsdam Deutsches GeoForschungsZentrum GFZ
#
# This program is free software: you can redistribute it and/or modify it
# under the terms of the GNU Affero General Public License as published by
# the Free Software Foundation, either version 3 of the License, or (at
# your option) any later version.
#
# This program is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero
# General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see http://www.gnu.org/licenses/.


import logging
import sys
22
23
24
import sqlite3
from database import JapanDatabase  # pylint: disable=E0611,E0401

Simantini Shinde's avatar
Simantini Shinde committed
25
26
27
28
29
30
31
32
33
34
35
36

# Add a logger printing error, warning, info and debug messages to the screen
logger = logging.getLogger()
logger.setLevel(logging.DEBUG)
logger.addHandler(logging.StreamHandler(sys.stdout))


def main():

    # Example logging output
    logger.info("exposurejapan started")

37
38
39
40
41
42
43
44
45
    db = JapanDatabase("test.sqlite", "/usr/lib64/mod_spatialite.so.7")

    try:
        db.create_connection_and_cursor()
    except sqlite3.OperationalError:
        logger.warning("Spatialite extension cannot be loaded. Exiting ...")
        exit()
    db.create_tables()
    db.read_districts_and_boundaries("../data/estat_bound_municipal.gpkg")
46
    db.import_exposure_data("../data/e008_3e.xlsx")
47

Simantini Shinde's avatar
Simantini Shinde committed
48
49
50
51
52
53
    # Leave the program
    sys.exit()


if __name__ == "__main__":
    main()