Library: SQLite
Package: SQLite
Header: Poco/Data/SQLite/Utility.h
Various utility functions for SQLite.
Member Functions: dbHandle, fileToMemory, getColumnType, getThreadMode, isThreadSafe, lastError, memoryToFile, registerUpdateHandler, setThreadMode, throwException
typedef int (* CommitCallbackType)(void *);
Commit callback function type.
typedef void (* RollbackCallbackType)(void *);
Rollback callback function type.
typedef std::map < std::string, MetaColumn::ColumnDataType > TypeMap;
typedef void (* UpdateCallbackType)(void *, int, const char *, const char *, Poco::Int64);
Update callback function type.
static sqlite3 * dbHandle(
const Session & session
);
Returns native DB handle.
static bool fileToMemory(
sqlite3 * pInMemory,
const std::string & fileName
);
Loads the contents of a database file on disk into an opened database in memory.
Returns true if succesful.
static bool fileToMemory(
const Session & session,
const std::string & fileName
);
Loads the contents of a database file on disk into an opened database in memory.
Returns true if succesful.
static MetaColumn::ColumnDataType getColumnType(
sqlite3_stmt * pStmt,
std::size_t pos
);
Returns column data type.
static int getThreadMode();
Returns the thread mode.
static bool isThreadSafe();
Returns true if SQLite was compiled in multi-thread or serialized mode. See http://www.sqlite.org/c3ref/threadsafe.html for details.
Returns true if succesful
static std::string lastError(
sqlite3 * pDb
);
Retreives the last error code from sqlite and converts it to a string.
static std::string lastError(
const Session & session
);
Retreives the last error code from sqlite and converts it to a string.
static bool memoryToFile(
const std::string & fileName,
sqlite3 * pInMemory
);
Saves the contents of an opened database in memory to the database on disk.
Returns true if succesful.
static bool memoryToFile(
const std::string & fileName,
const Session & session
);
Saves the contents of an opened database in memory to the database on disk.
Returns true if succesful.
template < typename T, typename CBT > static bool registerUpdateHandler(
sqlite3 * pDB,
CBT callbackFn,
T * pParam
);
Registers the callback for (1)(insert, delete, update), (2)(commit) or or (3)(rollback) events. Only one function per group can be registered at a time. Registration is not thread-safe. Storage pointed to by pParam must remain valid as long as registration is active. Registering with callbackFn set to zero disables notifications.
See http://www.sqlite.org/c3ref/update_hook.html and http://www.sqlite.org/c3ref/commit_hook.html for details.
template < typename T, typename CBT > static bool registerUpdateHandler(
const Session & session,
CBT callbackFn,
T * pParam
);
Registers the callback by calling registerUpdateHandler(sqlite3*, CBT, T*).
static bool setThreadMode(
int mode
);
Sets the threading mode to single, multi or serialized. See http://www.sqlite.org/threadsafe.html for details.
Returns true if succesful
static void throwException(
int rc,
const std::string & addErrMsg = std::string ()
);
Throws for an error code the appropriate exception
static const int OPERATION_DELETE;
static const int OPERATION_INSERT;
static const int OPERATION_UPDATE;
static const std::string SQLITE_DATE_FORMAT;
static const std::string SQLITE_TIME_FORMAT;
static const int THREAD_MODE_MULTI;
static const int THREAD_MODE_SERIAL;
static const int THREAD_MODE_SINGLE;