Skip to content

Commit

Permalink
Remove DBBrowserDB::tableColumns() method
Browse files Browse the repository at this point in the history
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...
  • Loading branch information
MKleusberg committed Apr 23, 2015
1 parent dd8dd48 commit 9b2529b
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 16 deletions.
15 changes: 1 addition & 14 deletions src/sqlitedb.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down Expand Up @@ -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;
}
2 changes: 0 additions & 2 deletions src/sqlitedb.h
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,6 @@ class DBBrowserDB : public QObject
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.
Expand Down

0 comments on commit 9b2529b

Please sign in to comment.