def get_overlapping_dataset_ids(self,
                                    dataset_id,
                                    delta_t=ONE_HOUR,
                                    tile_class_filter=(1, 3)):

        sql = ("SELECT DISTINCT od.dataset_id\n" +
               "FROM dataset d\n" +
               "INNER JOIN tile t USING (dataset_id)\n" +
               "INNER JOIN acquisition a USING (acquisition_id)\n" +
               "INNER JOIN tile o ON\n" +
               "    o.x_index = t.x_index AND\n" +
               "    o.y_index = t.y_index AND\n" +
               "    o.tile_type_id = t.tile_type_id\n" +
               "INNER JOIN dataset od ON\n" +
               "    od.dataset_id = o.dataset_id AND\n" +
               "    od.level_id = d.level_id\n" +
               "INNER JOIN acquisition oa ON\n" +
               "    oa.acquisition_id = od.acquisition_id AND\n" +
               "    oa.satellite_id = a.satellite_id\n" +
               "WHERE\n" +
               "    d.dataset_id = %(dataset_id)s\n" +
               ("    AND t.tile_class_id IN %(tile_class_filter)s\n" if
                tile_class_filter else "") +
               ("    AND o.tile_class_id IN %(tile_class_filter)s\n" if
                tile_class_filter else "") +
               "    AND (\n" +
               "        (oa.start_datetime BETWEEN\n" +
               "         a.start_datetime - %(delta_t)s AND\n" +
               "         a.end_datetime + %(delta_t)s)\n" +
               "     OR\n" +
               "        (oa.end_datetime BETWEEN\n" +
               "         a.start_datetime - %(delta_t)s AND\n" +
               "         a.end_datetime + %(delta_t)s)\n" +
               "    )\n" +
               "ORDER BY od.dataset_id;")

        params = {'dataset_id': dataset_id,
                  'delta_t': delta_t,
                  'tile_class_filter': tuple(tile_class_filter)
                  }
        result = self.execute_sql_multi(sql, params)
        dataset_id_list = [tup[0] for tup in result]
        return dataset_id_list
Make sure __str__/__unicode__ works correctly in Python 2/3
dataset/ETHPy150Open GeoscienceAustralia/agdc/src/abstract_ingester/ingest_db_wrapper.py/IngestDBWrapper.get_overlapping_dataset_ids--crossover with--dataset/ETHPy150Open recurly/recurly-client-python/tests/tests_errors.py/RecurlyExceptionTests.test_error_printable