Пример #1
0
def pudl_engine(ferc1_engine, live_pudl_db, live_ferc_db):
    """
    Grab a conneciton to the PUDL Database.

    If we are using the test database, we initialize the PUDL DB from scratch.
    If we're using the live database, then we just make a conneciton to it.
    """
    if not live_pudl_db:
        if live_ferc_db:
            ferc1_testing = False
        else:
            ferc1_testing = True
        init.init_db(ferc1_tables=pc.ferc1_pudl_tables,
                     ferc1_years=pc.working_years['ferc1'],
                     eia923_tables=pc.eia923_pudl_tables,
                     eia923_years=pc.working_years['eia923'],
                     eia860_tables=pc.eia860_pudl_tables,
                     eia860_years=pc.working_years['eia860'],
                     verbose=True,
                     debug=False,
                     pudl_testing=True,
                     ferc1_testing=ferc1_testing)

        # Grab a connection to the freshly populated PUDL DB, and hand it off.
        pudl_engine = init.connect_db(testing=True)
        yield (pudl_engine)

        # Clean up after ourselves by dropping the test DB tables.
        init.drop_tables(pudl_engine)
    else:
        print("Connecting to the live PUDL database.")
        yield (init.connect_db(testing=False))
Пример #2
0
def pudl_engine_travis_ci(ferc1_engine_travis_ci):
    """
    Grab a conneciton to the PUDL Database, with a limited amount of data.

    This fixture always initializes the DB from scratch, and only does a small
    subset of the data ETL, for structural testing within Travis CI.
    """
    init.init_db(ferc1_tables=pc.ferc1_pudl_tables,
                 ferc1_years=pc.travis_ci_ferc1_years,
                 eia923_tables=pc.eia923_pudl_tables,
                 eia923_years=pc.travis_ci_eia923_years,
                 eia860_tables=pc.eia860_pudl_tables,
                 eia860_years=pc.travis_ci_eia860_years,
                 epacems_years=pc.travis_ci_epacems_years,
                 epacems_states=pc.travis_ci_epacems_states,
                 verbose=True,
                 debug=False,
                 pudl_testing=True,
                 ferc1_testing=True)

    # Grab a connection to the freshly populated PUDL DB, and hand it off.
    pudl_engine = init.connect_db(testing=True)
    yield (pudl_engine)

    # Clean up after ourselves by dropping the test DB tables.
    init.drop_tables(pudl_engine)
Пример #3
0
def main():
    """The main function."""
    from pudl import init, constants
    from pudl import extract
    import pudl.models.glue
    import pudl.models.eia860
    import pudl.models.eia923
    import pudl.models.eia
    import pudl.models.ferc1

    args = parse_command_line(sys.argv)

    extract.ferc1.init_db(ferc1_tables=constants.ferc1_default_tables,
                          refyear=SETTINGS['ferc1_ref_year'],
                          years=SETTINGS['ferc1_years'],
                          def_db=True,
                          verbose=SETTINGS['verbose'],
                          testing=SETTINGS['ferc1_testing'])

    init.init_db(ferc1_tables=SETTINGS['ferc1_tables'],
                 ferc1_years=SETTINGS['ferc1_years'],
                 eia923_tables=SETTINGS['eia923_tables'],
                 eia923_years=SETTINGS['eia923_years'],
                 eia860_tables=SETTINGS['eia860_tables'],
                 eia860_years=SETTINGS['eia860_years'],
                 epacems_years=SETTINGS['epacems_years'],
                 epacems_states=SETTINGS['epacems_states'],
                 verbose=SETTINGS['verbose'],
                 debug=SETTINGS['debug'],
                 pudl_testing=SETTINGS['pudl_testing'],
                 ferc1_testing=SETTINGS['ferc1_testing'],
                 csvdir=SETTINGS['csvdir'],
                 keep_csv=SETTINGS['keep_csv'])
Пример #4
0
def main():
    """The main function."""
    from pudl import init, settings, constants
    from pudl import extract
    import pudl.models.entities
    import pudl.models.glue
    import pudl.models.eia860
    import pudl.models.eia923
    import pudl.models.eia
    import pudl.models.ferc1

    args = parse_command_line(sys.argv)

    extract.ferc1.init_db(ferc1_tables=constants.ferc1_default_tables,
                          refyear=args.ferc1_refyear,
                          years=range(args.ferc1_start, args.ferc1_end + 1),
                          def_db=True,
                          verbose=args.verbose,
                          testing=args.test)

    init.init_db(ferc1_tables=constants.ferc1_pudl_tables,
                 ferc1_years=range(args.ferc1_start, args.ferc1_end + 1),
                 eia923_tables=constants.eia923_pudl_tables,
                 eia923_years=range(args.eia923_start,
                                    args.eia923_end + 1),
                 eia860_tables=constants.eia860_pudl_tables,
                 eia860_years=range(args.eia860_start,
                                    args.eia860_end + 1),
                 epacems_years = range(args.epacems_start,
                                       args.epacems_end + 1),
                 epacems_states=args.epacems_states,
                 verbose=args.verbose,
                 debug=False,
                 pudl_testing=args.test,
                 ferc1_testing=args.test,
                 csvdir=args.csvdir,
                 keep_csv=args.keep_csv)