Compare commits
2 Commits
58840cecd0
...
4b15db7c1f
| Author | SHA1 | Date | |
|---|---|---|---|
| 4b15db7c1f | |||
| 6260264f04 |
@@ -29,6 +29,7 @@ MinGW: `pacman -S mingw-w64-x86_64-sqlite3`
|
||||
|
||||
6. To build library use tasks `build_static_lib[_dbg]` or `build_shared_lib[_dbg]`
|
||||
|
||||
7. If you use tsqlite as static library, add `LINKER_LIBS` from tsqlite `project.config` to your project.
|
||||
|
||||
## Usage
|
||||
```c
|
||||
|
||||
@@ -49,7 +49,10 @@ typedef struct tsqlite_statement {
|
||||
/// @return compiled statement
|
||||
Result(tsqlite_statement*) tsqlite_statement_compile(tsqlite_connection* conn, str sql_code);
|
||||
|
||||
void tsqlite_statement_free(tsqlite_statement* st);
|
||||
void tsqlite_statement_free(NULLABLE(tsqlite_statement*) st);
|
||||
|
||||
/// call this after executing a compiled statement to use it again
|
||||
void tsqlite_statement_reset(NULLABLE(tsqlite_statement*) st);
|
||||
|
||||
/// @brief execute statement or move to next result row.
|
||||
/// Documentation: https://sqlite.org/c3ref/step.html
|
||||
@@ -66,9 +69,6 @@ void tsqlite_statement_free(tsqlite_statement* st);
|
||||
/// @return is result row avaliable
|
||||
Result(bool) tsqlite_statement_step(tsqlite_statement* self);
|
||||
|
||||
/// call this after executing a compiled statement to use it again
|
||||
Result(void) tsqlite_statement_reset(tsqlite_statement* st);
|
||||
|
||||
/// Bind value to a placeholder
|
||||
Result(void) tsqlite_statement_bind_null(tsqlite_statement* self, cstr key);
|
||||
Result(void) tsqlite_statement_bind_i64(tsqlite_statement* self, cstr key, i64 v);
|
||||
|
||||
@@ -46,7 +46,7 @@ case "$OS" in
|
||||
SHARED_LIB_FILE="$PROJECT.dll"
|
||||
INCLUDE="$INCLUDE "
|
||||
# example: "-lSDL2 -lSDL2_image"
|
||||
LINKER_LIBS="-lsqlite3"
|
||||
LINKER_LIBS="-luuid -lsqlite3"
|
||||
;;
|
||||
LINUX)
|
||||
EXEC_FILE="test"
|
||||
|
||||
@@ -27,11 +27,12 @@ void tsqlite_statement_free(tsqlite_statement* self){
|
||||
free(self);
|
||||
}
|
||||
|
||||
Result(void) tsqlite_statement_reset(tsqlite_statement* self){
|
||||
try_sqlite3(self->conn, sqlite3_reset(self->st));
|
||||
void tsqlite_statement_reset(tsqlite_statement* self){
|
||||
if(!self)
|
||||
return;
|
||||
sqlite3_reset(self->st);
|
||||
self->result_row = -1;
|
||||
self->result_col = -1;
|
||||
return RESULT_VOID;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -46,7 +46,7 @@ Result(void) test_connection(){
|
||||
printf("ROW(%i):", st->result_row);
|
||||
for(i32 i = 0; i < column_count; i++){
|
||||
try_void(tsqlite_statement_getResult_str(st, &cell_str));
|
||||
printf(" [%i]='"FMT_str"'", st->result_col, str_expand(cell_str));
|
||||
printf(" [%i]='"FMT_str"'", st->result_col, str_unwrap(cell_str));
|
||||
}
|
||||
printf("\n");
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user