diff --git a/include/SQLiteCpp/Database.h b/include/SQLiteCpp/Database.h index 8696577..e31f545 100644 --- a/include/SQLiteCpp/Database.h +++ b/include/SQLiteCpp/Database.h @@ -336,6 +336,25 @@ public: apApp, apFunc, apStep, apFinal, apDestroy); } + + /** + * @brief Load a module into the current sqlite database instance. + * + * This is the equivalent of the sqlite3_load_extension call, but additionally enables + * module loading support prior to loading the requested module. + * + * @see http://www.sqlite.org/c3ref/load_extension.html + * + * @note UTF-8 text encoding assumed. + * + * @param[in] apExtensionName Name of the shared library containing extension + * @param[in] apEntryPointName Name of the entry point (NULL to let sqlite work it out) + * + * @throw SQLite::Exception in case of error + */ + void loadExtension(const char* apExtensionName, + const char *apEntryPointName); + private: /// @{ Database must be non-copyable Database(const Database&); diff --git a/src/Database.cpp b/src/Database.cpp index 6fe39bf..cd04584 100644 --- a/src/Database.cpp +++ b/src/Database.cpp @@ -151,5 +151,18 @@ void Database::createFunction(const char* apFuncName, check(ret); } +// Load an extension into the sqlite database. Only affects the current connection. +// Parameter details can be found here: http://www.sqlite.org/c3ref/load_extension.html +void Database::loadExtension(const char* apExtensionName, + const char *apEntryPointName) +{ + int ret = sqlite3_enable_load_extension(mpSQLite, 1); + + check(ret); + + ret = sqlite3_load_extension(mpSQLite, apExtensionName, apEntryPointName, 0); + + check(ret); +} } // namespace SQLite