kopia lustrzana https://gitlab.com/tomaszg/geostat
Add SQLite transactions
rodzic
d2682e5860
commit
f7e02612d8
7
ocdb.cpp
7
ocdb.cpp
|
@ -56,7 +56,7 @@ bool OCdb::init(std::string dump_path) {
|
||||||
json j;
|
json j;
|
||||||
file >> j;
|
file >> j;
|
||||||
revision = j["revision"];
|
revision = j["revision"];
|
||||||
|
request("BEGIN TRANSACTION;");
|
||||||
request("INSERT INTO revision VALUES (" + std::to_string(revision) + ");");
|
request("INSERT INTO revision VALUES (" + std::to_string(revision) + ");");
|
||||||
|
|
||||||
for (auto& el : j["data_files"].items()) {
|
for (auto& el : j["data_files"].items()) {
|
||||||
|
@ -85,14 +85,15 @@ bool OCdb::update(Okapi& oc) {
|
||||||
std::string output = oc.get_changelog_json(revision);
|
std::string output = oc.get_changelog_json(revision);
|
||||||
json j = json::parse(output);
|
json j = json::parse(output);
|
||||||
|
|
||||||
|
request("BEGIN TRANSACTION;");
|
||||||
for (auto& el : j["changelog"].items()) {
|
for (auto& el : j["changelog"].items()) {
|
||||||
parse_item(el.value());
|
parse_item(el.value());
|
||||||
}
|
}
|
||||||
revision = j["revision"];
|
revision = j["revision"];
|
||||||
|
request("UPDATE revision SET revision = " + std::to_string(revision) + ';');
|
||||||
|
request("COMMIT");
|
||||||
if (j["more"])
|
if (j["more"])
|
||||||
update(oc);
|
update(oc);
|
||||||
else
|
|
||||||
request("UPDATE revision SET revision = " + std::to_string(revision) + ';');
|
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Ładowanie…
Reference in New Issue