from typing import List


def mysql_dump_command(
    url: str, port: int, username: str, password: str, database: str,
    tables: List[str] = [],
) -> List[str]:
    """
    Generate a command to dump a database. The resulting command can be used by
    subprocess.call() with the stdout attribute set to a file object.
    :param url: Database server host name.
    :param port: Database server port number.
    :param username: Database server username.
    :param password: Database server password.
    :param database: Name of the database.
    :param tables: List of tables to use (optional). Defaults to all tables in the database.
    """
    return [
        "mysqldump",
        "-u",
        username,
        f"-p{password}",
        "-h",
        url,
        "-P",
        str(port),
        "--set-gtid-purged=OFF",
        "--triggers",
        "--routines",
        database,
        *tables,
    ]