last_result = desired_result
    lower_limit_guess = 0
    result = func_base(upper_limit_guess)
    while result > 0 and upper_limit_guess < 100:
        lower_limit_guess = upper_limit_guess
        upper_limit_guess *= 2
        last_result = result
        result = func_base(upper_limit_guess)

    return (lower_limit_guess, last_result, min(upper_limit_guess,
                                                100), result)


if __name__ == '__main__':
    config_reader.initialize()

    source_dbc = DbConnect(config_reader.get_source_db_connection_info())
    destination_dbc = DbConnect(
        config_reader.get_destination_db_connection_info())
    temp_schema = 'subset_' + str(uuid.uuid4()).replace('-', '')

    # Get list of tables to operate on
    all_tables = list_all_tables(source_dbc.get_db_connection())
    all_tables = [
        x for x in all_tables if x not in config_reader.get_excluded_tables()
    ]

    lower_limit, lower_limit_norm, upper_limit, upper_limit_norm = compute_fast_limits(
    )
    max_tries = config_reader.get_max_tries()
Exemplo n.º 2
0
from subset_utils import print_progress
import database_helper


def db_creator(db_type, source, dest):
    if db_type == 'postgres':
        return PsqlDatabaseCreator(source, dest, False)
    elif db_type == 'mysql':
        return MySqlDatabaseCreator(source, dest)
    else:
        raise ValueError('unknown db_type ' + db_type)


if __name__ == '__main__':
    if "--stdin" in sys.argv:
        config_reader.initialize(sys.stdin)
    else:
        config_reader.initialize()

    db_type = config_reader.get_db_type()
    source_dbc = DbConnect(db_type,
                           config_reader.get_source_db_connection_info())
    destination_dbc = DbConnect(
        db_type, config_reader.get_destination_db_connection_info())

    database = db_creator(db_type, source_dbc, destination_dbc)
    database.teardown()
    database.create()

    # Get list of tables to operate on
    db_helper = database_helper.get_specific_helper()