def query(cls): with DatabaseFactory.create_connection() as db: return db.fetchall('select code from %s' % cls.__table__)
def __init__(self, tablename, idname = 'id', connection = 'default'): dbname = DatabaseFactory.get_property(connection, 'dbname') self.tablename = dbname + '.' + tablename self.idname = idname self.db = DatabaseFactory.instance(connection)
def set_source(self): self.db = DatabaseFactory.sqlDb(self.dbpath)