1 /* Invisible Vector Library
2 * coded by Ketmar // Invisible Vector <ketmar@ketmar.no-ip.org>
3 * Understanding is not required. Only obedience.
5 * This program is free software: you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation, version 3 of the License ONLY.
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License
15 * along with this program. If not, see <http://www.gnu.org/licenses/>.
17 module sq3_test
/*is aliced*/;
26 static immutable schema
=
27 "PRAGMA auto_vacuum = NONE;\n"~
28 "PRAGMA journal_mode = MEMORY; /*MEMORY;*/ /*PERSIST;*/ /*WAL;*/ /*MEMORY;*/\n"~
29 "PRAGMA synchronous = OFF;\n"~
30 "PRAGMA encoding = \"UTF-8\";\n"~
32 "CREATE TABLE IF NOT EXISTS test(\n"~
33 " id INTEGER PRIMARY KEY\n"~
37 "CREATE UNIQUE INDEX IF NOT EXISTS testindex ON test(text);\n"~
43 ////////////////////////////////////////////////////////////////////////////////
45 try { import std
.file
: remove
; remove("test.db"); } catch (Exception
) {}
47 writeln("opening db...");
48 auto db = Database("test.db", schema
);
49 writeln("starting the transaction");
50 db.execute("begin transaction;");
51 writeln("creating the statement");
52 auto stmt
= db.statement("INSERT INTO test (id,text) VALUES(NULL,:text);");
54 stmt
.bind(":text", n
"ÈÕÊ!");
58 stmt
.bind(":text", n
"ÐÉÚÄÁ!");
62 stmt
.bind(":text", n
"ÒÁÚ-Ä×Á!");
65 writeln("commiting the transaction");
66 db.execute("commit transaction;");
68 auto stx
= db.statement("SELECT text AS text FROM test WHERE :a=:a;");
70 foreach (auto row
; sty
.bindConstText(":a", "boo!").range
) {
72 writeln("idx=", row
.index_
, "; type=", row
.text
!DBFieldType
, "; val=<", row
.text
!SQ3Text
, ">");
75 char[] cc = row.text!(char[]);
77 SQ3Text ct = row.text!SQ3Text;
79 string cs = row.text!string;
83 writeln("closing the db");