2 Commits
0.0.1 ... 0.0.2

Author SHA1 Message Date
9743ac15d9 memory bugfix, vbump 2020-01-26 22:14:25 +01:00
e239ac2b7f docs: better example 2020-01-26 16:06:06 +01:00
5 changed files with 12 additions and 8 deletions

View File

@@ -6,7 +6,7 @@ everything, but it tries to be useful.
## Installation
```clojure
(load "https://veitheller.de/git/carpentry/sqlite3@0.0.1")
(load "https://veitheller.de/git/carpentry/sqlite3@0.0.2")
```
## Usage

View File

@@ -43,8 +43,9 @@ databases.</p>
; ignore that
(let-do [db (Result.unsafe-from-success (SQLite3.open &quot;db&quot;))]
; we can prepare statements
(println* &amp;(SQLite3.query &amp;db &quot;INSERT INTO mytable VALUES (?1, ?2);&quot;
&amp;[(to-sqlite3 @&quot;hello&quot;) (to-sqlite3 100)]))
(ignore
(SQLite3.query &amp;db &quot;INSERT INTO mytable VALUES (?1, ?2);&quot;
&amp;[(to-sqlite3 @&quot;hello&quot;) (to-sqlite3 100)]))
; and query things
(println* &amp;(SQLite3.query &amp;db &quot;SELECT * from mytable;&quot; &amp;[]))
(SQLite3.close db)

View File

@@ -1,6 +1,8 @@
(load "sqlite3.carp")
(use SQLite3)
(add-cflag "-fsanitize=address")
(defn main []
(let-do [db (Result.unsafe-from-success (SQLite3.open "test.db"))]
; we can create a table

View File

@@ -7,7 +7,7 @@ to wrap everything, but it tries to be useful.
## Installation
```clojure
(load \"https://veitheller.de/git/carpentry/sqlite3@0.0.1\")
(load \"https://veitheller.de/git/carpentry/sqlite3@0.0.2\")
```
## Usage
@@ -22,8 +22,9 @@ databases.
; ignore that
(let-do [db (Result.unsafe-from-success (SQLite3.open \"db\"))]
; we can prepare statements
(println* &(SQLite3.query &db \"INSERT INTO mytable VALUES (?1, ?2);\"
&[(to-sqlite3 @\"hello\") (to-sqlite3 100)]))
(ignore
(SQLite3.query &db \"INSERT INTO mytable VALUES (?1, ?2);\"
&[(to-sqlite3 @\"hello\") (to-sqlite3 100)]))
; and query things
(println* &(SQLite3.query &db \"SELECT * from mytable;\" &[]))
(SQLite3.close db)

View File

@@ -176,14 +176,14 @@ const char* SQLite3_exec_internal(sqlite3_stmt* s, SQLiteRows* rows) {
break;
case SQLITE_TEXT: {
len = sqlite3_column_bytes(s, i);
c->s = CARP_MALLOC(len);
c->s = CARP_MALLOC(len+1);
memcpy(c->s, sqlite3_column_text(s, i), len);
c->s[len] = '\0';
break;
}
case SQLITE_BLOB: {
len = sqlite3_column_bytes(s, i);
c->s = CARP_MALLOC(len);
c->s = CARP_MALLOC(len+1);
memcpy(c->s, sqlite3_column_blob(s, i), len);
c->s[len] = '\0';
break;