Logo Search packages:      
Sourcecode: relational version File versions  Download package

def relational::relation::relation::delete (   self,
  expr 
)
Delete, expr must be a valid boolean expression, can contain field names,
constant, math operations and boolean ones.
This operation will change the relation itself instead of generating a new one,
deleting all the tuples that make expr true.
Returns the number of affected rows.

Definition at line 481 of file relation.py.

                         :
        '''Delete, expr must be a valid boolean expression, can contain field names,
        constant, math operations and boolean ones.
        This operation will change the relation itself instead of generating a new one,
        deleting all the tuples that make expr true.
        Returns the number of affected rows.'''
        attributes={}
        affected=len(self.content)
        new_content=[] #New content of the relation
        for i in self.content:
            for j in range(len(self.header.attributes)):
                if i[j].isdigit():
                    attributes[self.header.attributes[j]]=int(i[j])
                elif rstring(i[j]).isFloat():
                    attributes[self.header.attributes[j]]=float(i[j])
                elif isDate(i[j]):
                    attributes[self.header.attributes[j]]=rdate(i[j])
                else:
                    attributes[self.header.attributes[j]]=i[j]
            if not eval(expr,attributes):
                affected-=1
                new_content.append(i)
        self.content=new_content
        return affected

Generated by  Doxygen 1.6.0   Back to index