Delete dataset from upload schema

def delete_publication(self, pub_id, schema='upload'):
        """ Delete dataset from upload schema"""
        if schema == 'upload':
            user = 'upload_admin'
        elif schema == 'public':
            user = 'catroot'

        if not self.user == 'catroot':
            assert self.user == user, \
                "You don't have permission to perform this operation"

        con = self.connection or self._connect()
        cur = con.cursor()

        self.stdout.write('Deleting publication: {pub_id} from {schema}\n'
                          .format(pub_id=pub_id, schema=schema))

        cur.execute("""SELECT to_regclass('keys');""")
        if cur.fetchone()[0] is not None:  # remove data from old tables
            old_tables = ['text_key_values', 'number_key_values',
                          'species', 'keys']
            for table in old_tables:
                cur.execute(
                    """DELETE FROM {schema}.{table}"""
                    .format(schema=schema,
                            table=table))

        cur.execute(
            """DELETE FROM {schema}.systems
            WHERE unique_id in
            (SELECT distinct ase_id
            FROM {schema}.publication_system
            WHERE pub_id = '{pub_id}')"""
            .format(schema=schema,
                    pub_id=pub_id))

        cur.execute(
            """ DELETE FROM {schema}.publication
            WHERE pub_id = '{pub_id}'"""
            .format(schema=schema,
                    pub_id=pub_id))

        self.stdout.write('Delete complete\n')

        if self.connection is None:
            con.commit()
            con.close()
        return