Commit 71e1f662 authored by Marco Bubke's avatar Marco Bubke

Sqlite: Add excute to the database

To execute some simple pragmas etc..

Change-Id: Iaa74406a182897dd55ee3ee8dc4d4b94bb8a8e11
Reviewed-by: Tim Jenssen's avatarTim Jenssen <tim.jenssen@qt.io>
parent a279b554
......@@ -105,6 +105,11 @@ int SqliteDatabase::totalChangesCount()
return m_databaseBackend.totalChangesCount();
}
void SqliteDatabase::execute(Utils::SmallStringView sqlStatement)
{
m_databaseBackend.execute(sqlStatement);
}
void SqliteDatabase::initializeTables()
{
for (SqliteTable *table: tables())
......
......@@ -64,6 +64,8 @@ public:
int changesCount();
int totalChangesCount();
void execute(Utils::SmallStringView sqlStatement);
private:
void initializeTables();
SqliteDatabaseBackend &backend();
......
......@@ -89,7 +89,7 @@ void SqliteTable::initialize()
createTableSqlStatementBuilder.setColumnDefinitions(createColumnDefintions());
SqliteImmediateTransaction transaction(*m_sqliteDatabase);
SqliteWriteStatement(createTableSqlStatementBuilder.sqlStatement(), *m_sqliteDatabase).step();
m_sqliteDatabase->execute(createTableSqlStatementBuilder.sqlStatement());
transaction.commit();
m_isReady = true;
......
......@@ -263,10 +263,10 @@ void SqliteStatement::SetUp()
{
database.setJournalMode(JournalMode::Memory);
database.open(":memory:");
SqliteWriteStatement("CREATE TABLE test(name TEXT UNIQUE, number NUMERIC)", database).step();
SqliteWriteStatement("INSERT INTO test VALUES ('bar', 'blah')", database).step();
SqliteWriteStatement("INSERT INTO test VALUES ('foo', 23.3)", database).step();
SqliteWriteStatement("INSERT INTO test VALUES ('poo', 40)", database).step();
database.execute("CREATE TABLE test(name TEXT UNIQUE, number NUMERIC)");
database.execute("INSERT INTO test VALUES ('bar', 'blah')");
database.execute("INSERT INTO test VALUES ('foo', 23.3)");
database.execute("INSERT INTO test VALUES ('poo', 40)");
}
void SqliteStatement::TearDown()
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment