import getpass


def get_mysql_pwd(config):
    """Get the MySQL password from the config file or an interactive prompt."""
    # Two ways to get the password are supported.
    #
    # 1. Read clear-text password from config file. (least secure)
    # 2. Read password as entered manually from a console prompt. (most secure)

    # First try the config file. This is the least secure method. Protect the file.
    #mysql_pwd = config.get('mysql', 'mysql_pwd', 0)
    mysql_pwd = config['mysql'].get('mysql_pwd')

    # Try other method if config file password is blank or missing.
    if mysql_pwd == '':
        # Prompt for the password. More secure, but won't work unattended.
        mysql_pwd = getpass.getpass()

    return(mysql_pwd)