File Information
Library: Data/SQLite
Package: SQLite
Header: Poco/Data/SQLite/Utility.h
Description
Various utility functions for SQLite.
Member Summary
Member Functions: dbHandle, fileToMemory, getColumnType, getThreadMode, isThreadSafe, lastError, memoryToFile, registerUpdateHandler, setThreadMode, throwException
Nested Classes
class SQLiteMutex
Types
CommitCallbackType
typedef int (* CommitCallbackType)(void *);
Commit callback function type.
RollbackCallbackType
typedef void (* RollbackCallbackType)(void *);
Rollback callback function type.
TypeMap
typedef std::map < std::string, MetaColumn::ColumnDataType > TypeMap;
UpdateCallbackType
typedef void (* UpdateCallbackType)(void *, int, const char *, const char *, Poco::Int64);
Update callback function type.
Enumerations
TransactionType
Constructors
Member Functions
dbHandle
static sqlite3 * dbHandle(
const Session & session
);
Returns native DB handle.
fileToMemory
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.
fileToMemory
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.
getColumnType
static MetaColumn::ColumnDataType getColumnType(
sqlite3_stmt * pStmt,
std::size_t pos
);
Returns column data type.
getThreadMode
static int getThreadMode();
Returns the thread mode.
isThreadSafe
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
lastError
static std::string lastError(
sqlite3 * pDB
);
Retreives the last error code from sqlite and converts it to a string.
lastError
static std::string lastError(
const Session & session
);
Retreives the last error code from sqlite and converts it to a string.
memoryToFile
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.
memoryToFile
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.
registerUpdateHandler
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.
registerUpdateHandler
template < typename T, typename CBT > static bool registerUpdateHandler(
const Session & session,
CBT callbackFn,
T * pParam
);
Registers the callback by calling registerUpdateHandler(sqlite3*, CBT, T*).
setThreadMode
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
throwException
static void throwException(
sqlite3 * pDB,
int rc,
const std::string & addErrMsg = std::string ()
);
Throws for an error code the appropriate exception
Variables
OPERATION_DELETE
static const int OPERATION_DELETE;
OPERATION_INSERT
static const int OPERATION_INSERT;
OPERATION_UPDATE
static const int OPERATION_UPDATE;
SQLITE_DATE_FORMAT
static const std::string SQLITE_DATE_FORMAT;
SQLITE_TIME_FORMAT
static const std::string SQLITE_TIME_FORMAT;
THREAD_MODE_MULTI
static const int THREAD_MODE_MULTI;
THREAD_MODE_SERIAL
static const int THREAD_MODE_SERIAL;
THREAD_MODE_SINGLE
static const int THREAD_MODE_SINGLE;
TRANSACTION_TYPE_PROPERTY_KEY
static const std::string TRANSACTION_TYPE_PROPERTY_KEY;