Skip to content

surrealdb/surrealdb.c


 

The official SurrealDB SDK for C.


   

     

surrealdb.c

The official SurrealDB SDK for C.

Getting started

Warning

There is an issue with cbindgen which causes incorrect ordering of header files, so linking may fail.
This should be fixed soon, or can be worked around by using a published header file or manually reordering

Connect to an in-memory instance, SurrealKV or remote

#include "path/to/surrealdb.h"

sr_surreal_t *db;
sr_string_t err;

// connect to server
char *endpoint = "ws://localhost:8000";
// connect to file
char *endpoint = "surrealkv://database.skv";

if (sr_connect(&err, &db, endpoint) < 0)
{
    printf("failed to connect: %s", err);
    return 1;
}

sr_surreal_disconnect(db);