add bdb test
This commit is contained in:
parent
a44b2423f2
commit
dd436399cf
|
@ -87,6 +87,9 @@ if(${BUILD_WITH_BDB})
|
|||
IMPORTED_LOCATION "${CMAKE_CURRENT_SOURCE_DIR}/bdb/libdb.a"
|
||||
INTERFACE_INCLUDE_DIRECTORIES "${CMAKE_CURRENT_SOURCE_DIR}/bdb"
|
||||
)
|
||||
target_link_libraries(bdb
|
||||
INTERFACE pthread
|
||||
)
|
||||
endif(${BUILD_WITH_BDB})
|
||||
|
||||
# SQLite
|
||||
|
|
|
@ -1,7 +1,28 @@
|
|||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#include "db.h"
|
||||
|
||||
// refer: https://docs.oracle.com/cd/E17076_05/html/gsg/C/BerkeleyDB-Core-C-GSG.pdf
|
||||
|
||||
int main(int argc, char const *argv[]) {
|
||||
printf("Hello world!\n");
|
||||
DB * db;
|
||||
int ret;
|
||||
uint32_t flags;
|
||||
|
||||
ret = db_create(&db, NULL, 0);
|
||||
if (ret != 0) {
|
||||
exit(1);
|
||||
}
|
||||
|
||||
flags = DB_CREATE;
|
||||
|
||||
ret = db->open(db, NULL, "test.db", NULL, DB_BTREE, flags, 0);
|
||||
if (ret != 0) {
|
||||
exit(1);
|
||||
}
|
||||
|
||||
db->close(db, 0);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue