Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Menu
Open sidebar
Shawn Webb
liblattutil
Commits
4078182f
Commit
4078182f
authored
Jul 19, 2021
by
Shawn Webb
Browse files
Document the SQLit3 abstraction API
Signed-off-by:
Shawn Webb
<
shawn.webb@hardenedbsd.org
>
parent
a178b793
Changes
1
Hide whitespace changes
Inline
Side-by-side
README.md
View file @
4078182f
...
...
@@ -25,7 +25,7 @@ Do not terminate the log message with a newline.
Sample syslog logging code:
```
```
C
#include <liblattutil.h>
lattutil_log_t *logp;
...
...
@@ -45,3 +45,46 @@ logp->ll_log_info(logp, 2, "This debugging message will get ignored"
logp->ll_log_info(logp, 5, "This will get logged");
lattutil_log_free(&logp);
```
## SQLite3 Queries
liblattutil has a SQLite3 abstraction layer. Right now, it only
supports those data types that I myself care about. I'm open to
accepting patches for supporting unimplemented data types.
The sqlite3 APIs also support the logging APIs described above. When
creating a sqlite3 context, you have the option of specifying a
logging context object. Error, info, and debugging messages will be
reported through the logging object.
Sample sqlite3 code:
```
C
#include <liblattutil.h>
lattutil_sqlite_query_t *query;
lattutil_sqlite_ctx_t *ctx;
const ucl_object_t *row;
ctx = lattutil_sqlite_ctx_new("/tmp/db.sqlite3", NULL, 0);
if (ctx == NULL) {
Fatal();
}
query = lattutil_sqlite_prepare(ctx, "SELECT id FROM table WHERE id = ?");
if (query == NULL) {
Fatal();
}
if (!lattutil_sqlite_bind_int(query, 1, 1234)) {
Fatal();
}
if (!lattutil_sqlite_exec(query)) {
Fatal();
}
row = lattutil_sqlite_get_row(query, 0);
printf("ID: %ld\n", lattutil_sqlite_get_column_int(row, 0, 0));
```
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment