Exemplo n.º 1
0
def load(
    state,
    host,
    remote_filename,
    database=None,
    # Details for speaking to MySQL via `mysql` CLI
    mysql_user=None,
    mysql_password=None,
    mysql_host=None,
    mysql_port=None,
):
    '''
    Load ``.sql`` file into a database.

    + database: name of the database to import into
    + remote_filename: the filename to read from
    + mysql_*: global module arguments, see above
    '''

    yield '{0} < {1}'.format(
        make_mysql_command(
            database=database,
            user=mysql_user,
            password=mysql_password,
            host=mysql_host,
            port=mysql_port,
        ), remote_filename)
Exemplo n.º 2
0
def dump(
    state,
    host,
    remote_filename,
    database=None,
    # Details for speaking to MySQL via `mysql` CLI
    mysql_user=None,
    mysql_password=None,
    mysql_host=None,
    mysql_port=None,
):
    '''
    Dump a MySQL database into a ``.sql`` file. Requires ``mysqldump``.

    + database: name of the database to dump
    + remote_filename: name of the file to dump the SQL to
    + mysql_*: global module arguments, see above
    '''

    yield '{0} > {1}'.format(
        make_mysql_command(
            executable='mysqldump',
            database=database,
            user=mysql_user,
            password=mysql_password,
            host=mysql_host,
            port=mysql_port,
        ), remote_filename)
Exemplo n.º 3
0
def load(
    src, database=None,
    # Details for speaking to MySQL via `mysql` CLI
    mysql_user=None, mysql_password=None,
    mysql_host=None, mysql_port=None,
    state=None, host=None,
):
    '''
    Load ``.sql`` file into a database.

    + src: the filename to read from
    + database: name of the database to import into
    + mysql_*: global module arguments, see above

    Example:

    .. code:: python

        mysql.load(
            name='Import the pyinfra_stuff dump into pyinfra_stuff_copy',
            src='/tmp/pyinfra_stuff.dump',
            database='pyinfra_stuff_copy',
        )
    '''

    yield '{0} < {1}'.format(make_mysql_command(
        database=database,
        user=mysql_user,
        password=mysql_password,
        host=mysql_host,
        port=mysql_port,
    ), src)
Exemplo n.º 4
0
def dump(
    dest, database=None,
    # Details for speaking to MySQL via `mysql` CLI
    mysql_user=None, mysql_password=None,
    mysql_host=None, mysql_port=None,
    state=None, host=None,
):
    '''
    Dump a MySQL database into a ``.sql`` file. Requires ``mysqldump``.

    + dest: name of the file to dump the SQL to
    + database: name of the database to dump
    + mysql_*: global module arguments, see above

    Example:

    .. code:: python

        mysql.dump(
            name='Dump the pyinfra_stuff database',
            dest='/tmp/pyinfra_stuff.dump',
            database='pyinfra_stuff',
        )
    '''

    yield '{0} > {1}'.format(make_mysql_command(
        executable='mysqldump',
        database=database,
        user=mysql_user,
        password=mysql_password,
        host=mysql_host,
        port=mysql_port,
    ), dest)
Exemplo n.º 5
0
def dump(
    dest,
    database=None,
    # Details for speaking to MySQL via `mysql` CLI
    mysql_user=None,
    mysql_password=None,
    mysql_host=None,
    mysql_port=None,
):
    """
    Dump a MySQL database into a ``.sql`` file. Requires ``mysqldump``.

    + dest: name of the file to dump the SQL to
    + database: name of the database to dump
    + mysql_*: global module arguments, see above

    **Example:**

    .. code:: python

        mysql.dump(
            name="Dump the pyinfra_stuff database",
            dest="/tmp/pyinfra_stuff.dump",
            database="pyinfra_stuff",
        )
    """

    yield "{0} > {1}".format(
        make_mysql_command(
            executable="mysqldump",
            database=database,
            user=mysql_user,
            password=mysql_password,
            host=mysql_host,
            port=mysql_port,
        ),
        dest,
    )
Exemplo n.º 6
0
def load(
    src,
    database=None,
    # Details for speaking to MySQL via `mysql` CLI
    mysql_user=None,
    mysql_password=None,
    mysql_host=None,
    mysql_port=None,
):
    """
    Load ``.sql`` file into a database.

    + src: the filename to read from
    + database: name of the database to import into
    + mysql_*: global module arguments, see above

    **Example:**

    .. code:: python

        mysql.load(
            name="Import the pyinfra_stuff dump into pyinfra_stuff_copy",
            src="/tmp/pyinfra_stuff.dump",
            database="pyinfra_stuff_copy",
        )
    """

    yield "{0} < {1}".format(
        make_mysql_command(
            database=database,
            user=mysql_user,
            password=mysql_password,
            host=mysql_host,
            port=mysql_port,
        ),
        src,
    )