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))
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)