Files
mongo/examples/c/ex_hello.c
Michael Cahill b65420c0bd More work on documentation and examples, removed some things from the API, incorporated some of Keith's feedback.
--HG--
branch : mjc
rename : examples/c/ex_schema.c => examples/c/ex_call_center.c
extra : transplant_source : %AE%E9%C4%0B%3A%C5%0EH%E1%A8%A2L%E6%D2%D6%40G%9Dzq
2010-12-16 22:54:09 +11:00

39 lines
978 B
C

/*
* ex_hello.c Copyright (c) 2010 WiredTiger
*
* This is an example demostrating how to create and connect to a database.
*/
#include <stdio.h>
#include <string.h>
#include <wiredtiger.h>
const char *home = "WT_TEST";
int main()
{
int ret;
WT_CONNECTION *conn;
WT_SESSION *session;
/* Open a connection to the database, creating it if necessary. */
if ((ret = wiredtiger_open(home, NULL, "create", &conn)) != 0)
fprintf(stderr, "Error connecting to %s: %s\n",
home, wiredtiger_strerror(ret));
/* Open a session for the current thread's work. */
if ((ret = conn->open_session(conn, NULL, NULL, &session)) != 0)
fprintf(stderr, "Error opening a session on %s: %s\n",
home, wiredtiger_strerror(ret));
/* Do some work... */
/* Note: closing the connection implicitly closes open session(s). */
if ((ret = conn->close(conn, NULL)) != 0)
fprintf(stderr, "Error connecting to %s: %s\n",
home, wiredtiger_strerror(ret));
return (ret);
}