在沒有安裝R程序包的情況下,是否可以使用MonetDBLite作爲C++應用程序中的存儲引擎?或者有沒有其他方式將MonetDB用作SQLite等嵌入式數據庫?在C++/Qt應用程序中沒有R的MonetDBLite
回答
你可以使用這個從C/C++等,像這樣:
下載/克隆從GitHub https://github.com/hannesmuehleisen/MonetDBLite將R包源,然後轉到src
文件夾和運行配置:
./configure --enable-embedded --disable-fits --disable-geom --disable-rintegration --disable-gsl --disable-netcdf --disable-jdbc --disable-merocontrol --disable-odbc --disable-console --disable-microhttpd --without-openssl --without-uuid --without-curl --without-bz2 --without-lzma --without-libxml2 --without-perl --without-python2 --without-python3 --without-unixodbc --disable-mapi --without-samtools --without-sphinxclient --without-geos --without-samtools --without-readline --enable-optimize --enable-silent-rules --disable-int128
與make -j
構建它(這將需要一段時間)
然後,您可以構建一個MonetDBLite共享庫如下:
gcc -shared -o libmonetdb5.so `find common gdk mal/mal mal/modules mal/optimizer sql embedded -name "*.o" | tr "\n" " "` -lpthread -lpcre -lz -liconv
你應該有一個大(5 MB)最終文件libmonetdb5.so包含所有MonetDBLite代碼。現在使用它從自己的程序:
下面是使用嵌入式MonetDB一個C程序示例:
#include "monetdb_config.h"
#include "sql_scenario.h"
#include "mal.h"
#include "embedded.h"
int main() {
char* err = NULL;
void* conn = NULL;
res_table* result = NULL;
err = monetdb_startup("/tmp/embedded-dbfarm", 1, 0);
if (err != NULL) {
fprintf(stderr, "Init fail: %s\n", err);
return -1;
}
conn = monetdb_connect();
err = monetdb_query(conn, "SELECT * FROM tables;", 1, (void**) &result);
if (err != NULL) {
fprintf(stderr, "Query fail: %s\n", err);
return -2;
}
fprintf(stderr, "Query result with %i cols and %lu rows\n", result->nr_cols, BATcount(BATdescriptor(result->cols[0].b)));
monetdb_disconnect(conn);
monetdb_shutdown();
}
保存到這一點在src
文件夾中的文件(在這裏,test.c
),並構建它:
gcc test.c -Icommon/options -Icommon/stream -Igdk -Imal/mal -Imal/modules/atoms -Imal/modules/mal -Isql/include -Isql/backends/monet5 -Isql/server -Isql/common -Isql/storage -Iembedded -lmonetdb5 -L.
這應該是所有的,當你運行它(./a.out
),應該說Query result with 9 cols and 44 rows
。請注意,您只需將libmonetdb5.so
文件與編譯的程序一起發送,而不是源碼樹的其餘部分。
作爲一個旁註,我們希望在未來簡化這一過程。
- 1. 應用程序沒有出現在應用程序列表中?
- 2. GUI在多線程應用程序的Wxwidgets中沒有響應
- 3. 在應用程序引擎中沒有入口點的Web應用程序?
- 4. 有沒有辦法在我的應用程序中使用mstest
- 5. 有沒有在c#應用程序中使用ffmpeg的方法?
- 6. 沒有API的Web應用程序的Android應用程序
- 7. 有沒有API的應用程序?
- 8. NSTextView沒有在沒有停靠圖標的應用程序中響應
- 9. 在android應用程序中沒有得到url的響應
- 10. Windows Metro應用程序中沒有P2P?
- 11. Android中沒有背景應用程序
- 12. java.library.path中沒有應用程序
- 13. ListView沒有出現在應用程序
- 14. 應用程序沒有在Android
- 15. 在執行過程中沒有內存的應用程序
- 16. iPhone在應用郵件中沒有返回到應用程序
- 17. Android應用程序沒有顯示在應用程序抽屜中
- 18. Camerabuttons事件只是沒有在WP7.1應用程序中觸發應用程序
- 19. 在java SE應用程序(使用netbeans)中有沒有picturebox
- 20. Glassfish web應用程序沒有響應
- 21. 對Web應用程序沒有響應
- 22. 應用程序沒有響應
- 23. 應用程序沒有響應
- 24. Spring應用程序沒有響應
- 25. XNA應用程序沒有響應
- 26. 應用程序沒有響應
- 27. phonegap android應用程序沒有響應
- 28. 應用程序沒有響應
- 29. 應用程序沒有響應
- 30. DotCloud:應用程序沒有響應
另請參見新的MonetDBLite-C示例,這裏:https://github.com/hannesmuehleisen/MonetDBLite-C#usage-example –