<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def download_database(connection, container: str, target: str=""):
 """ Download database dump """


    meta_data = objectstore.get_full_container_list(
        connection, container, prefix='database')

    options = return_file_objects(connection, container)

    for o_info in meta_data:
        expected_file = f'database.{ENV}'

        LOG.info(o_info['name'])

        if o_info['name'].startswith(expected_file):
            dt = dateparser.parse(o_info['last_modified'])
            # now = datetime.datetime.now()
            options.append((dt, o_info))

        options.sort()

    if not options:
        LOG.error('Dumps missing? ENVIRONMENT wrong? (acceptance / production')
        LOG.error('Environtment {ENV}')
        sys.exit(1)

    newest = options[-1][1]

    LOG.debug('Downloading: %s', (newest['name']))

    target_file = os.path.join(target, expected_file)

    LOG.info('TARGET: %s', target_file)

    if os.path.exists(target_file):
        LOG.info('Already downloaded')
        return

    LOG.error('TARGET does not exists downloading...')

    new_data = objectstore.get_object(connection, newest, container)

    # save output to file!
    with open(target_file, 'wb') as outputzip:
        outputzip.write(new_data)