<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def delete_metadata_for_uri(self, uri):
 """Delete metadata for a URI in the metadata database. A hash will be constructed from the supplied uri and a lookup made in a local SQLITE database for the metadata. If there is an existing record for the hash, the entire record will be erased. .. seealso:: write_metadata_for_uri, read_metadata_for_uri :param uri: A layer uri. e.g. ```dbname=\'osm\' host=localhost port=5432 user=\'foo\'password=\'bar\' sslmode=disable key=\'id\' srid=4326``` :type uri: str """

        hash_value = self.hash_for_datasource(uri)
        try:
            cursor = self.get_cursor()
            # now see if we have any data for our hash
            sql = 'delete from metadata where hash = \'' + hash_value + '\';'
            cursor.execute(sql)
            self.connection.commit()
        except sqlite.Error as e:
            LOGGER.debug("SQLITE Error %s:" % e.args[0])
            self.connection.rollback()
        except Exception as e:
            LOGGER.debug("Error %s:" % e.args[0])
            self.connection.rollback()
            raise
        finally:
            self.close_connection()