def create_table(self, db: Database, uid_key: str, keys: List[str]) -> Table: query = self.query if self.nrows is None: try: self.nrows = db.count(query) except (ValueError, KeyError) as e: error = ', '.join(['Bad query'] + list(e.args)) from flask import flash flash(error) query = 'id=0' # this will return no rows self.nrows = 0 table = Table(db, uid_key) table.select(query, self.columns, self.sort, self.limit, offset=self.page * self.limit, show_empty_columns=True) table.format() assert self.columns is not None table.addcolumns = sorted(column for column in all_columns + keys if column not in self.columns) return table
def create_table(self, db: Database, uid_key: str) -> Table: query = self.query if self.nrows is None: try: self.nrows = db.count(query) except (ValueError, KeyError) as e: error = ', '.join(['Bad query'] + list(e.args)) flash(error) query = 'id=0' # this will return no rows self.nrows = 0 table = Table(db, uid_key) table.select(query, self.columns, self.sort, self.limit, offset=self.page * self.limit) table.format() table.addcolumns = sorted(column for column in all_columns + table.keys if column not in table.columns) return table