<commit_before>import sh
from bakthat import app
from helper import BakHelper

__author__ = 'alex'


@app.cmd(help="Copies a dump of the database.")
@app.cmd_arg('-u', '--user', type=str, help='The database administrator.', default='root')
@app.cmd_arg('-p', '--password', type=str, help='User password', default='')
@app.cmd_arg('-b', '--backupname', type=str, help='Name (optional) backup file', default='host_mysql')
@app.cmd_arg('-d', '--destination', type=str, help="s3plus", default='s3plus')
@app.cmd_arg('-database', '--database', type=str)
def mysqldump(user='root', password='', **kwargs):
    with BakHelper(kwargs['backupname'], destination=kwargs['destination'],
                   password=password, tags=["mysql"]) as bh:
        sh.mysqldump("-p{0}".format(password), u=user, d=kwargs['database'],
                    _out="dump_{0}.sql".format(kwargs['database']))
        bh.backup()<commit_msg>Adicionando parâmetro host para o dump do mysql.<commit_after>import sh
from bakthat import app
from helper import BakHelper

__author__ = 'alex'


@app.cmd(help="Copies a dump of the database.")
@app.cmd_arg('-u', '--user', type=str, help='The database administrator.', default='root')
@app.cmd_arg('-p', '--password', type=str, help='User password', default='')
@app.cmd_arg('-b', '--backupname', type=str, help='Name (optional) backup file', default='host_mysql')
@app.cmd_arg('-host', '--host', type=str, help='Mysql host', default=None)
@app.cmd_arg('-d', '--destination', type=str, help="s3plus", default='s3plus')
@app.cmd_arg('-database', '--database', type=str)
def mysqldump(user='root', password='', **kwargs):
    with BakHelper(kwargs['backupname'], destination=kwargs['destination'],
                   password=password, tags=["mysql"]) as bh:

        mysql_kwargs = dict(
            u=user,
            d=kwargs['database'],
            _out="dump_{0}.sql".format(kwargs['database']))

        if kwargs.get('host') is not None:
            mysql_kwargs['h'] = kwargs['host']

        sh.mysqldump("-p{0}".format(password), **mysql_kwargs)
        bh.backup()
{'fraction_non_alphanumeric': 0.20047846889952153, 'fraction_numerical': 0.003827751196172249, 'mean_word_length': 4.403100775193798, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, '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': '1272204', 'n_tokens_mistral': 680, 'n_tokens_neox': 665, 'n_words': 148}