Rewrite electricity-logger to use an sqlite3 database
This commit is contained in:
9
include/migrator/migrations.hpp
Normal file
9
include/migrator/migrations.hpp
Normal file
@@ -0,0 +1,9 @@
|
||||
#pragma once
|
||||
#include <string>
|
||||
|
||||
namespace Migrations
|
||||
{
|
||||
int EpochToDateTime(std::string const & sourceDatabase, std::string const & destinationDatabase);
|
||||
|
||||
int UpdateSummaryTable(std::string const & sourceDatabase, std::string const & destinationDatabase);
|
||||
}
|
||||
24
include/migrator/transaction.hpp
Normal file
24
include/migrator/transaction.hpp
Normal file
@@ -0,0 +1,24 @@
|
||||
#pragma once
|
||||
#include <sqlite3.h>
|
||||
#include <sstream>
|
||||
|
||||
class Transaction {
|
||||
private:
|
||||
sqlite3 * const destination;
|
||||
unsigned queryCount;
|
||||
std::stringstream queryStream;
|
||||
|
||||
void Reset();
|
||||
|
||||
public:
|
||||
void AddStatement(std::string const & statement);
|
||||
|
||||
unsigned StatementCount() const;
|
||||
|
||||
// Runs the statements inserted as a single transaction
|
||||
// Returns a SQLite status code (0 = OK) and then resets
|
||||
// to a new transaction
|
||||
int Execute();
|
||||
|
||||
Transaction(sqlite3 * const databaseToInsertIn);
|
||||
};
|
||||
Reference in New Issue
Block a user