test-platform/server/cgi/db/object_pool.py

11 lines
341 B
Python

class ObjectPool:
def __init__(self, selector, constructor):
self.selector = selector
self.constructor = constructor
self.pool = []
def load_from_db(self, cur):
cur.execute(f"SELECT * FROM {self.selector};")
self.pool = [self.constructor().init_from_data(i) for i in cur]
return self