Get row counts and sizes for materialized tables
(self)
| 201 | return result |
| 202 | |
| 203 | def get_table_stats(self) -> Dict[str, Dict[str, int]]: |
| 204 | """Get row counts and sizes for materialized tables""" |
| 205 | stats = {} |
| 206 | |
| 207 | for source, table_name in self.TABLE_NAMES.items(): |
| 208 | try: |
| 209 | # Get row count |
| 210 | row_count = self.conn.execute( |
| 211 | f"SELECT COUNT(*) FROM {table_name}" |
| 212 | ).fetchone()[0] |
| 213 | |
| 214 | # Get approximate table size (this is a rough estimate) |
| 215 | col_count = len(self.conn.execute( |
| 216 | f"DESCRIBE {table_name}" |
| 217 | ).fetchall()) |
| 218 | |
| 219 | stats[source] = { |
| 220 | 'rows': row_count, |
| 221 | 'columns': col_count |
| 222 | } |
| 223 | except: |
| 224 | stats[source] = {'rows': 0, 'columns': 0} |
| 225 | |
| 226 | return stats |