C
|
Connection options for C ArcadeDB exposes multiple wire protocols, so you can pick the one your stack already speaks:
There is no actively maintained Neo4j BOLT driver for plain C. If you need Cypher from C, the easiest path is to call out to one of the BOLT-capable languages (Python, Go) over an FFI, or use the HTTP/JSON API and target the OpenCypher endpoint. |
PostgreSQL Wire Protocol — libpq
#include <stdio.h>
#include <libpq-fe.h>
int main(void) {
PGconn *conn = PQconnectdb(
"host=localhost port=5432 dbname=mydatabase user=root password=playwithdata");
if (PQstatus(conn) != CONNECTION_OK) {
fprintf(stderr, "connection failed: %s", PQerrorMessage(conn));
PQfinish(conn);
return 1;
}
PGresult *res = PQexec(conn, "SELECT FROM schema:types LIMIT 5");
for (int i = 0; i < PQntuples(res); i++)
printf("%s\n", PQgetvalue(res, i, 0));
PQclear(res);
PQfinish(conn);
return 0;
}
Build:
gcc example.c -lpq -o example
HTTP/JSON API — libcurl
#include <curl/curl.h>
int main(void) {
CURL *curl = curl_easy_init();
curl_easy_setopt(curl, CURLOPT_URL,
"http://localhost:2480/api/v1/query/mydatabase");
curl_easy_setopt(curl, CURLOPT_USERPWD, "root:playwithdata");
struct curl_slist *headers = NULL;
headers = curl_slist_append(headers, "Content-Type: application/json");
curl_easy_setopt(curl, CURLOPT_HTTPHEADER, headers);
const char *body =
"{\"language\":\"sql\","
" \"command\":\"SELECT FROM schema:types LIMIT 5\"}";
curl_easy_setopt(curl, CURLOPT_POSTFIELDS, body);
curl_easy_perform(curl);
curl_slist_free_all(headers);
curl_easy_cleanup(curl);
return 0;
}
Build:
gcc example.c -lcurl -o example