Create, insert and access a simple table.
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <wiredtiger.h>
static const char *home;
int
main(void)
{
const char *key, *value;
int ret;
if (getenv("WIREDTIGER_HOME") == NULL) {
home = "WT_HOME";
ret = system("rm -rf WT_HOME && mkdir WT_HOME");
} else
home = NULL;
(ret = conn->
open_session(conn, NULL, NULL, &session)) != 0) {
fprintf(stderr, "Error connecting to %s: %s\n",
return (EXIT_FAILURE);
}
ret = session->
create(session,
"table:access", "key_format=S,value_format=S");
"table:access", NULL, NULL, &cursor);
ret = cursor->
reset(cursor);
while ((ret = cursor->
next(cursor)) == 0) {
ret = cursor->
get_key(cursor, &key);
printf("Got record: %s : %s\n", key, value);
}
ret = conn->
close(conn, NULL);
return (ret == 0 ? EXIT_SUCCESS : EXIT_FAILURE);
}