|
cwist
Modern C web framework with libttak runtime
|
Database operations wrapper (SQLite3). More...

Go to the source code of this file.
Classes | |
| struct | cwist_db |
| Wrapper for Database Operations. Currently uses SQLite3. More... | |
Typedefs | |
| typedef struct cwist_db | cwist_db |
Functions | |
Lifecycle | |
| cwist_error_t | cwist_db_open (cwist_db **db, const char *path) |
| Connect to a database (or open file). | |
| void | cwist_db_close (cwist_db *db) |
| Close database connection. | |
Execution | |
| cwist_error_t | cwist_db_exec (cwist_db *db, const char *sql) |
| Execute a command (INSERT, UPDATE, DELETE, CREATE). Does not return rows. | |
| cwist_error_t | cwist_db_query (cwist_db *db, const char *sql, cJSON **result) |
| Execute a query and return results as a cJSON Array of Objects. Example: [{"id":1, "name":"foo"}, {"id":2, "name":"bar"}]. | |
Database operations wrapper (SQLite3).
Definition in file sql.h.
| cwist_error_t cwist_db_exec | ( | cwist_db * | db, |
| const char * | sql | ||
| ) |
Execute a command (INSERT, UPDATE, DELETE, CREATE). Does not return rows.
Execute a command (INSERT, UPDATE, DELETE, CREATE). Does not return rows.
| db | Open database wrapper. |
| sql | SQL text to execute. |
Definition at line 312 of file db.c.
Referenced by cwist_db_insert_healed().
| cwist_error_t cwist_db_open | ( | cwist_db ** | db, |
| const char * | path | ||
| ) |
Connect to a database (or open file).
| db | Out parameter for the database handle. |
| path | Path to SQLite file (or ":memory:"). |
Connect to a database (or open file).
| db | Output pointer receiving the allocated database wrapper. |
| path | Filesystem path or SQLite URI to open. |
| cwist_error_t cwist_db_query | ( | cwist_db * | db, |
| const char * | sql, | ||
| cJSON ** | result | ||
| ) |
Execute a query and return results as a cJSON Array of Objects. Example: [{"id":1, "name":"foo"}, {"id":2, "name":"bar"}].
Execute a query and return results as a cJSON Array of Objects. Example: [{"id":1, "name":"foo"}, {"id":2, "name":"bar"}].
| db | Open database wrapper. |
| sql | SQL text to execute. |
| result | Output pointer receiving the cJSON row array. |
Definition at line 374 of file db.c.
Referenced by cwist_db_query_strict().