diff options
Diffstat (limited to 'tools/perf/scripts/python/exported-sql-viewer.py')
-rwxr-xr-x | tools/perf/scripts/python/exported-sql-viewer.py | 25 |
1 files changed, 13 insertions, 12 deletions
diff --git a/tools/perf/scripts/python/exported-sql-viewer.py b/tools/perf/scripts/python/exported-sql-viewer.py index 58a95241ff70..7bd5263d3f39 100755 --- a/tools/perf/scripts/python/exported-sql-viewer.py +++ b/tools/perf/scripts/python/exported-sql-viewer.py | |||
@@ -1821,12 +1821,13 @@ class SQLTableModel(TableModel): | |||
1821 | 1821 | ||
1822 | progress = Signal(object) | 1822 | progress = Signal(object) |
1823 | 1823 | ||
1824 | def __init__(self, glb, sql, column_count, parent=None): | 1824 | def __init__(self, glb, sql, column_headers, parent=None): |
1825 | super(SQLTableModel, self).__init__(parent) | 1825 | super(SQLTableModel, self).__init__(parent) |
1826 | self.glb = glb | 1826 | self.glb = glb |
1827 | self.more = True | 1827 | self.more = True |
1828 | self.populated = 0 | 1828 | self.populated = 0 |
1829 | self.fetcher = SQLFetcher(glb, sql, lambda x, y=column_count: SQLTableDataPrep(x, y), self.AddSample) | 1829 | self.column_headers = column_headers |
1830 | self.fetcher = SQLFetcher(glb, sql, lambda x, y=len(column_headers): SQLTableDataPrep(x, y), self.AddSample) | ||
1830 | self.fetcher.done.connect(self.Update) | 1831 | self.fetcher.done.connect(self.Update) |
1831 | self.fetcher.Fetch(glb_chunk_sz) | 1832 | self.fetcher.Fetch(glb_chunk_sz) |
1832 | 1833 | ||
@@ -1864,6 +1865,12 @@ class SQLTableModel(TableModel): | |||
1864 | def HasMoreRecords(self): | 1865 | def HasMoreRecords(self): |
1865 | return self.more | 1866 | return self.more |
1866 | 1867 | ||
1868 | def columnCount(self, parent=None): | ||
1869 | return len(self.column_headers) | ||
1870 | |||
1871 | def columnHeader(self, column): | ||
1872 | return self.column_headers[column] | ||
1873 | |||
1867 | # SQL automatic table data model | 1874 | # SQL automatic table data model |
1868 | 1875 | ||
1869 | class SQLAutoTableModel(SQLTableModel): | 1876 | class SQLAutoTableModel(SQLTableModel): |
@@ -1873,12 +1880,12 @@ class SQLAutoTableModel(SQLTableModel): | |||
1873 | if table_name == "comm_threads_view": | 1880 | if table_name == "comm_threads_view": |
1874 | # For now, comm_threads_view has no id column | 1881 | # For now, comm_threads_view has no id column |
1875 | sql = "SELECT * FROM " + table_name + " WHERE comm_id > $$last_id$$ ORDER BY comm_id LIMIT " + str(glb_chunk_sz) | 1882 | sql = "SELECT * FROM " + table_name + " WHERE comm_id > $$last_id$$ ORDER BY comm_id LIMIT " + str(glb_chunk_sz) |
1876 | self.column_headers = [] | 1883 | column_headers = [] |
1877 | query = QSqlQuery(glb.db) | 1884 | query = QSqlQuery(glb.db) |
1878 | if glb.dbref.is_sqlite3: | 1885 | if glb.dbref.is_sqlite3: |
1879 | QueryExec(query, "PRAGMA table_info(" + table_name + ")") | 1886 | QueryExec(query, "PRAGMA table_info(" + table_name + ")") |
1880 | while query.next(): | 1887 | while query.next(): |
1881 | self.column_headers.append(query.value(1)) | 1888 | column_headers.append(query.value(1)) |
1882 | if table_name == "sqlite_master": | 1889 | if table_name == "sqlite_master": |
1883 | sql = "SELECT * FROM " + table_name | 1890 | sql = "SELECT * FROM " + table_name |
1884 | else: | 1891 | else: |
@@ -1891,14 +1898,8 @@ class SQLAutoTableModel(SQLTableModel): | |||
1891 | schema = "public" | 1898 | schema = "public" |
1892 | QueryExec(query, "SELECT column_name FROM information_schema.columns WHERE table_schema = '" + schema + "' and table_name = '" + select_table_name + "'") | 1899 | QueryExec(query, "SELECT column_name FROM information_schema.columns WHERE table_schema = '" + schema + "' and table_name = '" + select_table_name + "'") |
1893 | while query.next(): | 1900 | while query.next(): |
1894 | self.column_headers.append(query.value(0)) | 1901 | column_headers.append(query.value(0)) |
1895 | super(SQLAutoTableModel, self).__init__(glb, sql, len(self.column_headers), parent) | 1902 | super(SQLAutoTableModel, self).__init__(glb, sql, column_headers, parent) |
1896 | |||
1897 | def columnCount(self, parent=None): | ||
1898 | return len(self.column_headers) | ||
1899 | |||
1900 | def columnHeader(self, column): | ||
1901 | return self.column_headers[column] | ||
1902 | 1903 | ||
1903 | # Base class for custom ResizeColumnsToContents | 1904 | # Base class for custom ResizeColumnsToContents |
1904 | 1905 | ||