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]
def count_all(cls): """ 执行 select count(pk) from table语句,返回一个数值 """ return dbHandler.select('select count(`%s`) from `%s`' % (cls.__primay_key__.name, cls.__table__))
def find_all(cls, *args): """ 查询所有字段, 将结果以一个列表返回 """ L = dbHandler.select('select * from %s' % cls.__table__) return [cls(**d)for d in L]