From 9b2529bdf4c0f447961cd2aa6b8eee08ea07d9c7 Mon Sep 17 00:00:00 2001 From: Martin Kleusberg Date: Thu, 23 Apr 2015 22:39:05 +0200 Subject: [PATCH] Remove DBBrowserDB::tableColumns() method Remove the DBBrowserDB::tableColumns() method which queries the database for the column names of a given table and which is used for the SQL export only. This function isn't needed at all because it generates a whole bunch of queries for data which is already hold in memory... --- src/sqlitedb.cpp | 15 +-------------- src/sqlitedb.h | 2 -- 2 files changed, 1 insertion(+), 16 deletions(-) diff --git a/src/sqlitedb.cpp b/src/sqlitedb.cpp index 6bed1bd5..43bf2aad 100644 --- a/src/sqlitedb.cpp +++ b/src/sqlitedb.cpp @@ -428,7 +428,7 @@ bool DBBrowserDB::dump(const QString& filename, continue; // get columns - QStringList cols(tableColumns(it->getTableName())); + QStringList cols(it->table.fieldNames()); QString sQuery = QString("SELECT * FROM `%1`;").arg(it->getTableName()); QByteArray utf8Query = sQuery.toUtf8(); @@ -1237,16 +1237,3 @@ bool DBBrowserDB::loadExtension(const QString& filename) return false; } } - -QStringList DBBrowserDB::tableColumns(const QString & tableName) { - QStringList cols; - sqlite3_stmt* stmt = NULL; - QString q(QString("PRAGMA table_info('%1');").arg(tableName)); - int rc = sqlite3_prepare_v2(this->_db, q.toUtf8(), q.toUtf8().length(), &stmt, NULL); - if (rc == SQLITE_OK) { - while (sqlite3_step(stmt) == SQLITE_ROW) - cols.push_back(QString((const char*)sqlite3_column_text(stmt, 1))); - sqlite3_finalize(stmt); - } - return cols; -} diff --git a/src/sqlitedb.h b/src/sqlitedb.h index 03adcbeb..3e2687ad 100644 --- a/src/sqlitedb.h +++ b/src/sqlitedb.h @@ -58,8 +58,6 @@ public: bool executeSQL ( const QString & statement, bool dirtyDB=true, bool logsql=true); bool executeMultiSQL(const QString& statement, bool dirty = true, bool log = false); - QStringList tableColumns(const QString& tableName); - /** * @brief getRow Executes a sqlite statement to get the rowdata(columns) * for the given rowid.