forked from qt-creator/qt-creator
Sqlite: Improve Sqlite wrapper
It is now possible to read values at once. for (auto [name, value] : statement.tupleValues<String, int>(1000, "foo", 20)) .... Change-Id: I3d4bc5218810b4620e1df625126aa490f30bbc71 Reviewed-by: Tim Jenssen <tim.jenssen@qt.io>
This commit is contained in:
@@ -26,6 +26,7 @@
|
||||
#include "sqlitedatabase.h"
|
||||
|
||||
#include "sqlitetable.h"
|
||||
#include "sqlitetransaction.h"
|
||||
|
||||
namespace Sqlite {
|
||||
|
||||
@@ -34,6 +35,12 @@ SqliteDatabase::SqliteDatabase()
|
||||
{
|
||||
}
|
||||
|
||||
SqliteDatabase::SqliteDatabase(Utils::PathString &&databaseFilePath)
|
||||
: m_databaseBackend(*this)
|
||||
{
|
||||
open(std::move(databaseFilePath));
|
||||
}
|
||||
|
||||
void SqliteDatabase::open()
|
||||
{
|
||||
m_databaseBackend.open(m_databaseFilePath, m_openMode);
|
||||
@@ -61,7 +68,7 @@ bool SqliteDatabase::isOpen() const
|
||||
|
||||
SqliteTable &SqliteDatabase::addTable()
|
||||
{
|
||||
m_sqliteTables.emplace_back(*this);
|
||||
m_sqliteTables.emplace_back();
|
||||
|
||||
return m_sqliteTables.back();
|
||||
}
|
||||
@@ -118,8 +125,12 @@ void SqliteDatabase::execute(Utils::SmallStringView sqlStatement)
|
||||
|
||||
void SqliteDatabase::initializeTables()
|
||||
{
|
||||
SqliteImmediateTransaction<SqliteDatabase> transaction(*this);
|
||||
|
||||
for (SqliteTable &table : m_sqliteTables)
|
||||
table.initialize();
|
||||
table.initialize(*this);
|
||||
|
||||
transaction.commit();
|
||||
}
|
||||
|
||||
SqliteDatabaseBackend &SqliteDatabase::backend()
|
||||
|
Reference in New Issue
Block a user