Exemplo n.º 1
0
 def find_by(cls, where , *args):
     """
         通过where语句进行条件查询,将结果以一个列表返回
         """
     L = dbHandler.select('select * from `%s` %s' % (cls.__table__, where), *args)
     return [cls(**d) for d in L]
Exemplo n.º 2
0
 def count_all(cls):
     """
     执行 select count(pk) from table语句,返回一个数值
     """
     return dbHandler.select('select count(`%s`) from `%s`' % (cls.__primay_key__.name, cls.__table__))
Exemplo n.º 3
0
 def find_all(cls, *args):
     """
     查询所有字段, 将结果以一个列表返回
     """
     L = dbHandler.select('select * from %s' % cls.__table__)
     return [cls(**d)for d in L]