<commit_before># -*- coding: utf-8 -*-
from sqlalchemy import (Column, Float, ForeignKey, Integer, MetaData, String,
                        Table, join, create_engine, ForeignKeyConstraint,
                        Boolean, DateTime, Sequence)
from sqlalchemy.orm import sessionmaker, relationship, configure_mappers
# from sqlalchemy.ext.declarative import declarative_base
from sqlalchemy.ext.automap import automap_base
# from geoalchemy2 import Geometry, shape
import configparser as cp
# from sqlalchemy.sql import func
# from sqlalchemy.dialects import postgresql
import os.path as path

# read configuration file
FILENAME = 'config.ini'
FILE = path.join(path.expanduser("~"), '.open_eGo', FILENAME)
cfg = cp.ConfigParser()
cfg.read(FILE)

# establish db connection
section = 'Connection'
conn = create_engine(
    "postgresql+psycopg2://{user}:{password}@{host}:{port}/{db}".format(
        user=cfg.get(section, 'username'),
        password=cfg.get(section, 'password'),
        host=cfg.get(section, 'host'),
        port=cfg.get(section, 'port'),
        db=cfg.get(section, 'db')))

print("Connected to database.")


# establish  second db connection to
# change of init file in .open_ego and Server connetion via ssh required
section2 = 'Coastdat'
conn2 = create_engine(
    "postgresql+psycopg2://{user}:{password}@{host}:{port}/{db}".format(
        user=cfg.get(section2, 'username'),
        password=cfg.get(section2, 'password'),
        host=cfg.get(section2, 'host'),
        port=cfg.get(section2, 'port'),
        db=cfg.get(section2, 'db')))

print("Connected to database 2.")



# map schema
session = sessionmaker(bind=conn)()

meta = MetaData()
meta.bind = conn
meta.reflect(bind=conn, schema='calc_renpass_gis',
             only=['renpass_gis_scenario',
                   'renpass_gis_linear_transformer',
                   'renpass_gis_source',
                   'renpass_gis_sink',
                   'renpass_gis_storage'])

# map to classes
Base = automap_base(metadata=meta)
Base.prepare()

Scenario, LinearTransformer, Source, Sink, Storage = \
    Base.classes.renpass_gis_scenario,\
    Base.classes.renpass_gis_linear_transformer,\
    Base.classes.renpass_gis_source,\
    Base.classes.renpass_gis_sink,\
    Base.classes.renpass_gis_storage

# map schema of coastdat-2
session2 = sessionmaker(bind=conn)()

meta2 = MetaData()
meta2.bind = conn2
meta2.reflect(bind=conn2, schema='coastdat',
             only=['cosmoclmgrid',
                   'datatype',
                   'located',
                   'projection',
                   'scheduled',
                   'spatial',
                   'timeseries',                   
                   'typified',
                   'year'])


# map to classes of coastdat weather data
Coastdat = automap_base(metadata=meta2)
Coastdat.prepare()
<commit_msg>Revert "add second db connection to coastdat"<commit_after># -*- coding: utf-8 -*-
from sqlalchemy import (Column, Float, ForeignKey, Integer, MetaData, String,
                        Table, join, create_engine, ForeignKeyConstraint,
                        Boolean, DateTime, Sequence)
from sqlalchemy.orm import sessionmaker, relationship, configure_mappers
# from sqlalchemy.ext.declarative import declarative_base
from sqlalchemy.ext.automap import automap_base
# from geoalchemy2 import Geometry, shape
import configparser as cp
# from sqlalchemy.sql import func
# from sqlalchemy.dialects import postgresql
import os.path as path

# read configuration file
FILENAME = 'config.ini'
FILE = path.join(path.expanduser("~"), '.open_eGo', FILENAME)
cfg = cp.ConfigParser()
cfg.read(FILE)

# establish db connection
section = 'Connection'
conn = create_engine(
    "postgresql+psycopg2://{user}:{password}@{host}:{port}/{db}".format(
        user=cfg.get(section, 'username'),
        password=cfg.get(section, 'password'),
        host=cfg.get(section, 'host'),
        port=cfg.get(section, 'port'),
        db=cfg.get(section, 'db')))

print("Connected to database.")

# map schema
session = sessionmaker(bind=conn)()

meta = MetaData()
meta.bind = conn
meta.reflect(bind=conn, schema='calc_renpass_gis',
             only=['renpass_gis_scenario',
                   'renpass_gis_linear_transformer',
                   'renpass_gis_source',
                   'renpass_gis_sink',
                   'renpass_gis_storage'])

# map to classes
Base = automap_base(metadata=meta)
Base.prepare()

Scenario, LinearTransformer, Source, Sink, Storage = \
    Base.classes.renpass_gis_scenario,\
    Base.classes.renpass_gis_linear_transformer,\
    Base.classes.renpass_gis_source,\
    Base.classes.renpass_gis_sink,\
    Base.classes.renpass_gis_storage

{'fraction_non_alphanumeric': 0.11931093151850276, 'fraction_numerical': 0.004891535516801361, 'mean_word_length': 3.1804444444444444, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5380394', 'n_tokens_mistral': 1489, 'n_tokens_neox': 1429, 'n_words': 309}