Esempio n. 1
0
 def cursor(self):
     c = Query.get_cursor(self.rclass.db)
     def row_factory(q, row):
         o = self.rclass()
         for col,v in zip(q.description, row):
             if col[0] in o._fields:
                 f = o._fields[o._fields.index(col[0])]
                 setattr(o, f.name, f.to_python(v))
             else:
                 setattr(o, col[0], v)
         return o
     c.row_factory = row_factory
     return c
Esempio n. 2
0
    def cursor(self):
        c = Query.get_cursor(self.rclass.db)

        def row_factory(q, row):
            o = self.rclass()
            for col, v in zip(q.description, row):
                if col[0] in o._fields:
                    f = o._fields[o._fields.index(col[0])]
                    setattr(o, f.name, f.to_python(v))
                else:
                    setattr(o, col[0], v)
            return o

        c.row_factory = row_factory
        return c