Beispiel #1
0
 def update(self):
     args = list(map(self.get_value_or_default, self.__fields__))
     args.append(self.get_values(self.__primary_key__))
     rows = execute(self.__update__, args)
     if rows != 1:
         logging.warning('failed to update by primary key: affected rows: %s' % rows)
     return rows
Beispiel #2
0
 def save(self):
     args = list(map(self.get_value_or_default, self.__fields__))
     args.append(self.get_value_or_default(self.__primary_key__))
     rows = execute(self.__insert__, args)
     if rows != 1:
         logging.warning('failed to insert record: affected rows: %s' % rows)
     return rows
Beispiel #3
0
def create_tables(sqls):
    for sql in sqls:
        yield execute(sql)
Beispiel #4
0
 def remove(self):
     args = [self.get_values(self.__primary_key__)]
     rows = execute(self.__delete__, args)
     if rows != 1:
         logging.warning('failed to remove by primary key: affected rows: %s' % rows)
     return rows