data: saving and loading Storage with sqlite file next to project file
This commit is contained in:
@@ -7,7 +7,7 @@
|
||||
SqliteStorage::SqliteStorage(const std::string& dbFilePath)
|
||||
{
|
||||
m_database.open(dbFilePath.c_str());
|
||||
clear();
|
||||
setup();
|
||||
}
|
||||
|
||||
SqliteStorage::~SqliteStorage()
|
||||
@@ -15,12 +15,16 @@ SqliteStorage::~SqliteStorage()
|
||||
m_database.close();
|
||||
}
|
||||
|
||||
void SqliteStorage::setup()
|
||||
{
|
||||
m_database.execDML("PRAGMA foreign_keys=ON;");
|
||||
setupTables();
|
||||
}
|
||||
|
||||
void SqliteStorage::clear()
|
||||
{
|
||||
m_database.execDML("PRAGMA foreign_keys=OFF;");
|
||||
clearTables();
|
||||
m_database.execDML("PRAGMA foreign_keys=ON;");
|
||||
setupTables();
|
||||
}
|
||||
|
||||
void SqliteStorage::beginTransaction()
|
||||
|
||||
@@ -20,6 +20,7 @@ public:
|
||||
SqliteStorage(const std::string& dbFilePath);
|
||||
~SqliteStorage();
|
||||
|
||||
void setup();
|
||||
void clear();
|
||||
|
||||
void beginTransaction();
|
||||
|
||||
@@ -21,8 +21,8 @@
|
||||
#include "data/type/DataType.h"
|
||||
#include "settings/ApplicationSettings.h"
|
||||
|
||||
Storage::Storage()
|
||||
: m_sqliteStorage("data/test.sqlite")
|
||||
Storage::Storage(const FilePath& dbPath)
|
||||
: m_sqliteStorage(dbPath.str())
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
@@ -19,7 +19,7 @@ class Storage
|
||||
, public StorageAccess
|
||||
{
|
||||
public:
|
||||
Storage();
|
||||
Storage(const FilePath& dbPath);
|
||||
virtual ~Storage();
|
||||
|
||||
void clear();
|
||||
|
||||
Reference in New Issue
Block a user