예제 #1
0
 def find_first(cls, where, *args):
     """
         通过where语句进行条件查询,返回1个查询结果。如果有多个查询结果
         仅取第一个,如果没有结果,则返回None
     """
     d = dbHandler.select_one("select * from %s %s" % (cls.__table__, where), *args)
     return cls(**d) if d else None
예제 #2
0
 def get(cls, pk):
     d = dbHandler.select_one('select * from %s where %s =?' % (cls.__table__, cls.__primary_key__.name), pk)
     return cls(**d) if d else None