Exemple #1
0
 def delete(self):
     if self.__exist__ == False:
         logging.warning('删除失败,__exist__ = False')
         return False  #不是从表中取出的数据, 直接返回False
     sql_cmd = self.operation.delete(self)  # 生成sql语句
     logging.info('删除   %s' % sql_cmd)
     return executeSQL(sql_cmd)
Exemple #2
0
 def min(cls, cols):  # 参数不能是'*'且只能传入一个字段返回行数
     sql_cmd = cls.operation.sum(cls, cols, 'min')  # 生成sql语句
     logging.info('总和   %s' % sql_cmd)
     return queryNumber(sql_cmd)
Exemple #3
0
 def sum(cls, cols):  # 参数不能是'*'且只能传入一个字段返回行数 类似的还有 max min avg
     sql_cmd = cls.operation.sum(cls, cols)  # 生成sql语句
     logging.info('总和   %s' % sql_cmd)
     return queryNumber(sql_cmd)
Exemple #4
0
 def count(cls, cols='*'):  # 参数可以是"*"或者是一个字段
     sql_cmd = cls.operation.count(cls, cols)  # 生成sql语句
     logging.info('数量   %s' % sql_cmd)
     return queryNumber(sql_cmd)
Exemple #5
0
 def createTable(cls):  # 创建表
     sql_cmd = cls.operation.createTable(cls)  #生成sql语句
     logging.info('创建表=>%s' % sql_cmd)
     return executeSQL(sql_cmd)
Exemple #6
0
 def one(cls):
     sql_cmd = cls.operation.one(cls)  # 生成sql语句
     logging.info('数据(one)   %s' % sql_cmd)
     data = queryData(sql_cmd, cls)
     return data[0] if data != None and len(
         data) > 0 else None  #查询结果为零时返回None
Exemple #7
0
 def all(cls):
     sql_cmd = cls.operation.all(cls)  # 生成sql语句
     logging.info('数据(all)   %s' % sql_cmd)
     return queryData(sql_cmd, cls)
Exemple #8
0
 def update(self):
     if self.__exist__ == False:
         return self.save()  #不是从表中取出的数据, 更新时返回保存的sql名
     sql_cmd = self.operation.update(self)  # 生成sql语句
     logging.info('更新   %s' % sql_cmd)
     return executeSQL(sql_cmd)
Exemple #9
0
 def deleteOne(cls, *args, **kwargs):
     sql_cmd = cls.operation.deleteOne(cls, *args, **kwargs)  # 生成sql语句
     logging.info('deleteOne   %s' % sql_cmd)
     return executeSQL(sql_cmd)
Exemple #10
0
 def deleteAll(cls, *args, **kwargs):  # condition为None时删除所有
     sql_cmd = cls.operation.deleteAll(cls, *args, **kwargs)  # 生成sql语句
     logging.info('deleteAll   %s' % sql_cmd)
     return executeSQL(sql_cmd)
Exemple #11
0
 def save(self):
     sql_cmd = self.operation.save(self)  # 生成sql语句
     logging.info('插入   %s' % sql_cmd)
     return executeSQL(sql_cmd)
Exemple #12
0
 def updateOne(cls, mappings, *args, **kwargs):
     sql_cmd = cls.operation.updateOne(cls, mappings, *args,
                                       **kwargs)  # 生成sql语句
     logging.info('updateOne   %s' % sql_cmd)
     return executeSQL(sql_cmd)