2023-06-29 10:21:02 +03:00
|
|
|
/* gcc -I include example.c ../../target/debug/libsql_experimental.a ../../../.libs/libsqlite3.a && ./a.out */
|
2023-06-29 08:57:54 +03:00
|
|
|
|
|
|
|
#include "libsql.h"
|
|
|
|
#include <assert.h>
|
2023-06-29 14:05:28 +03:00
|
|
|
#include <stdio.h>
|
2023-06-29 08:57:54 +03:00
|
|
|
|
|
|
|
int main(int argc, char *argv[])
|
|
|
|
{
|
2023-06-29 14:05:28 +03:00
|
|
|
libsql_connection_t conn;
|
2023-07-02 13:23:47 +03:00
|
|
|
libsql_rows_t rows;
|
2023-06-29 14:05:28 +03:00
|
|
|
libsql_database_t db;
|
2023-06-29 08:57:54 +03:00
|
|
|
|
2023-06-29 19:56:38 +03:00
|
|
|
db = libsql_open_ext(":memory:");
|
2023-06-29 14:05:28 +03:00
|
|
|
if (!db) {
|
2023-06-29 08:57:54 +03:00
|
|
|
assert(0);
|
|
|
|
}
|
2023-06-29 14:05:28 +03:00
|
|
|
conn = libsql_connect(db);
|
|
|
|
if (!conn) {
|
|
|
|
assert(0);
|
|
|
|
}
|
2023-07-02 13:23:47 +03:00
|
|
|
rows = libsql_execute(conn, "SELECT 1");
|
|
|
|
if (!rows) {
|
2023-06-29 14:46:07 +03:00
|
|
|
assert(0);
|
|
|
|
}
|
2023-07-02 13:23:47 +03:00
|
|
|
for (int row = 0; row < libsql_row_count(rows); row++) {
|
|
|
|
for (int col = 0; col < libsql_column_count(rows); col++) {
|
2023-06-29 14:05:28 +03:00
|
|
|
if (col > 0) {
|
|
|
|
printf(", ");
|
|
|
|
}
|
2023-07-02 13:23:47 +03:00
|
|
|
const char *value = libsql_value_text(rows, row, col);
|
2023-06-29 14:05:28 +03:00
|
|
|
printf("%s", value);
|
|
|
|
}
|
|
|
|
}
|
2023-07-02 13:23:47 +03:00
|
|
|
libsql_free_rows(rows);
|
2023-06-29 14:05:28 +03:00
|
|
|
libsql_disconnect(conn);
|
|
|
|
libsql_close(db);
|
2023-06-29 08:57:54 +03:00
|
|
|
}
|