diff --git a/README.md b/README.md index 17af1b1..5aaa714 100644 --- a/README.md +++ b/README.md @@ -6,7 +6,7 @@ everything, but it tries to be useful. ## Installation ```clojure -(load "https://veitheller.de/git/carpentry/sqlite3@0.0.5") +(load "git@git.veitheller.de:carpentry/sqlite3.git@0.0.6") ``` ## Usage @@ -15,7 +15,7 @@ The module `SQLite3` provides facilities for opening, closing, and querying databases. ```clojure -(load "https://veitheller.de/git/carpentry/sqlite3@0.0.5") +(load "git@git.veitheller.de:carpentry/sqlite3.git@0.0.6") ; opening DBs can fail, for the purposes of this example we ; ignore that diff --git a/docs/SQLite3.html b/docs/SQLite3.html index 44fed8e..77fa1c3 100644 --- a/docs/SQLite3.html +++ b/docs/SQLite3.html @@ -18,26 +18,49 @@
-

- SQLite3 -

-
-

is a simple high-level wrapper around SQLite3. It doesn’t intend +

+

+ SQLite3 +

+
+

is a simple high-level wrapper around SQLite3. It doesn’t intend to wrap everything, but it tries to be useful.

Installation

-
(load "https://veitheller.de/git/carpentry/sqlite3@0.0.5")
+
(load "git@veitheller.de:git/carpentry/sqlite3.git@0.0.6")
 

Usage

The module SQLite3 provides facilities for opening, closing, and querying databases.

-
(load "https://veitheller.de/git/carpentry/sqlite3@0.0.5")
+
(load "git@veitheller.de:git/carpentry/sqlite3.git@0.0.6")
 
 ; opening DBs can fail, for the purposes of this example we
 ; ignore that
@@ -62,110 +85,113 @@ databases.

Because open and query return Result types, we could also use combinators!

-
-
- -

- SQLite -

-
-
- meta-stub
-

- a -

- - - -

-

is the opaque database type. You’ll need one of those to query +

+ +

+ SQLite +

+
+
+ meta-stub +
+

+ a +

+ + + +

+

is the opaque database type. You’ll need one of those to query anything.

It can be obtained by using open.

-

-
-
- -

- Type -

-
-
- module +

-

- Module -

- - - -

- -

-
-
- -

- close -

-
-
- external +
+ +

+ + Type + +

+ +
+ module +
+

+ Module +

+ + + +

+ +

-

- (Fn [SQLite] ()) -

- - - -

-

closes a database.

+
+ +

+ close +

+
+
+ external +
+

+ (Fn [SQLite] ()) +

+ + + +

+

closes a database.

-

-
-
- -

- open -

-
-
- defn +

-

- (Fn [(Ref String a)] (Result SQLite String)) -

-
-                    (open s)
-                
-

-

opens a database with the filename s.

+
+ +

+ open +

+
+
+ defn +
+

+ (Fn [(Ref String a)] (Result SQLite String)) +

+
+                        (open s)
+                    
+

+

opens a database with the filename s.

If it fails, we return an error message using Result.Error.

-

-
-
- -

- query -

-
-
- defn +

-

- (Fn [(Ref SQLite a), (Ref String b), (Ref (Array SQLite3.Type) c)] (Result (Array (Array SQLite3.Type)) String)) -

-
-                    (query db s p)
-                
-

-

queries the database db using the query s and the parameters +

+ +

+ query +

+
+
+ defn +
+

+ (Fn [(Ref SQLite a), (Ref String b), (Ref (Array SQLite3.Type) c)] (Result (Array (Array SQLite3.Type)) String)) +

+
+                        (query db s p)
+                    
+

+

queries the database db using the query s and the parameters p.

If it fails, we return an error message using Result.Error.

-

+

+
diff --git a/sqlite3.carp b/sqlite3.carp index 0aa8882..6d0abdb 100644 --- a/sqlite3.carp +++ b/sqlite3.carp @@ -7,7 +7,7 @@ to wrap everything, but it tries to be useful. ## Installation ```clojure -(load \"https://veitheller.de/git/carpentry/sqlite3@0.0.5\") +(load \"git@veitheller.de:git/carpentry/sqlite3.git@0.0.6\") ``` ## Usage @@ -16,7 +16,7 @@ The module `SQLite3` provides facilities for opening, closing, and querying databases. ```clojure -(load \"https://veitheller.de/git/carpentry/sqlite3@0.0.5\") +(load \"git@veitheller.de:git/carpentry/sqlite3.git@0.0.6\") ; opening DBs can fail, for the purposes of this example we ; ignore that @@ -88,6 +88,10 @@ primitive Carp types can be casted to appropriate SQLite types by using the (register text (Fn [String] SQLiteColumn) "SQLiteColumn_text") (register blob (Fn [String] SQLiteColumn) "SQLiteColumn_blob")) + (defn prn [s] + (SQLite3.Type.str s)) + (implements prn SQLite3.Type.prn) + (defn to-sqlite3-internal [x] (match x (Null) (SQLiteColumn.nil)