<commit_before>from getpass import getpass

from fabric import api


def dump(backup_path, database_name, user='root', host=None, password=None):
    """
    Backup MySQL database as a MySQL archive.
    If host is set to None, 127.0.0.1 will be used.
    If password is set to None, a prompt will ask a password.
    """
    if host is None:
        host = default_host

    if password is None:
        password = get_password(user)

    api.run('mysqldump {database_name} -h{host} -u{user} -p{password} > {backup_path}'
            .format(
                database_name=database_name,
                host=host,
                user=user,
                password=password,
                backup_path=backup_path,
            ))


def restore(backup_path, database_name, user='root', host=None, password=None):
    """
    Restore MySQL database.
    If host is set to None, 127.0.0.1 will be used.
    If password is set to None, a prompt will ask a password.
    """
    if host is None:
        host = default_host

    if password is None:
        password = get_password(user)

    api.run('mysql -h{host} -u{user} -p{password} {database_name} < {backup_path}'
            .format(
                database_name=database_name,
                host=host,
                user=user,
                password=password,
                backup_path=backup_path,
            ))


def default_host():
    """
    Return the default host
    """
    return '127.0.0.1'


def get_password(user):
    """
    Ask a password in the prompt
    """
    return getpass('Enter database password for {user}: '
                   .format(user=user))<commit_msg>use a constant for the default MySQL host<commit_after>from getpass import getpass

from fabric import api

DEFAULT_HOST = '127.0.0.1'


def dump(backup_path, database_name, user='root', host=None, password=None):
    """
    Backup MySQL database as a MySQL archive.
    If host is set to None, 127.0.0.1 will be used.
    If password is set to None, a prompt will ask a password.
    """
    if host is None:
        host = DEFAULT_HOST

    if password is None:
        password = <PASSWORD>_password(user)

    api.run('mysqldump {database_name} -h{host} -u{user} -p{password} > {backup_path}'
            .format(
                database_name=database_name,
                host=host,
                user=user,
                password=password,
                backup_path=backup_path,
            ))


def restore(backup_path, database_name, user='root', host=None, password=None):
    """
    Restore MySQL database.
    If host is set to None, 127.0.0.1 will be used.
    If password is set to None, a prompt will ask a password.
    """
    if host is None:
        host = DEFAULT_HOST

    if password is None:
        password = <PASSWORD>(user)

    api.run('mysql -h{host} -u{user} -p{password} {database_name} < {backup_path}'
            .format(
                database_name=database_name,
                host=host,
                user=user,
                password=password,
                backup_path=backup_path,
            ))


def get_password(user):
    """
    Ask a password in the prompt
    """
    return getpass('Enter database password for {user}: '
                   .format(user=user))
{'fraction_non_alphanumeric': 0.09939024390243903, 'fraction_numerical': 0.01097560975609756, 'mean_word_length': 1.9990859232175502, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 6, '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': '2940955', 'n_tokens_mistral': 999, 'n_tokens_neox': 938, 'n_words': 290}