from datetime import datetime


def get_database_backup_statement(filename, dbname, as_username='postgres'):
    """Returns the line to be executed to create a database
    dump file from postgresql.
        Arguments:
            filename: Name of the file to create.
            dbname: Name from the database.
            as_username: Name from the username to use when connecting
                         to postgresql
    """
    now = datetime.now()
    statement = 'sudo -u {username} pg_dump {dbname} > {filename}'.format(
        username=as_username, dbname=dbname, filename=filename
        )
    return statement