2 #include "sqlite3x_settings_db.hpp" 31 return 0 != this->m_db;
67 static std::string SettingsDb_Set_SQL =
"insert into settings values(?,?)";
89 st.
bind( 2, val ? 1 : 0 );
113 st.
bind( 2, val ? val :
"" );
117 void settings_db::init()
119 this->m_db->
executenonquery(
"create table if not exists settings(key PRIMARY KEY ON CONFLICT REPLACE,value)" );
124 static std::string SettingsDb_Get_SQL =
"select value from settings where key = ?";
settings_db()
Creates an unopened database.
Encapsulates a command to send to an sqlite3_connection.
void executenonquery()
Executes the query and provides no way to get the results.
bool get(std::string const &key, int &val)
Fetches the given key from the db.
bool is_open() const
Returns true if open() has succeeded.
This namespace encapsulates a C++ API wrapper for sqlite3 databases.
Represents a connection to an sqlite3 database.
void clear()
Empties the database.
void close()
Closes this database.
void set(std::string const &key, int val)
Sets the given key/value pair.
void close()
Closes this database.
~settings_db()
Closes this database.
std::string executestring()
Executes the query, which is expected to have a string or blob field as the first result field...
int64_t executeint64()
Executes the query, which is expected to have a (int64_t) field as the first result field...
double executedouble()
Executes the query, which is expected to have a double field as the first result field.
void bind(int index)
Binds NULL to the given index.
void executenonquery(const std::string &sql)
Executes a command which is assumed to have a single step and a void result.
void open(std::string const &dbname)
Opens the database dbname or throws on error.
sqlite3_connection * db()
If you want low-level info about the db, here's the handle to it.
int executeint()
Executes the query, which is expected to have an integer field as the first result field...