forked from Shmuma/sqlite3-mt4-wrapper
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest.mq4
47 lines (36 loc) · 1.15 KB
/
test.mq4
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
#include "sqlite.mqh"
bool do_check_table_exists (string db, string table)
{
int res = sqlite_table_exists (db, table);
if (res < 0) {
Print ("Check for table existence failed with code " + res);
return (false);
}
return (res > 0);
}
void do_exec (string db, string exp)
{
int res = sqlite_exec (db, exp);
if (res != 0)
Print ("Expression '" + exp + "' failed with code " + res);
}
int start ()
{
string db = "test.db";
if (!do_check_table_exists (db, "test")) {
Print ("DB not exists, create schema");
do_exec (db, "create table test (name text)");
do_exec (db, "insert into test (name) values ('test1')");
do_exec (db, "insert into test (name) values ('test2')");
do_exec (db, "insert into test (name) values ('test3')");
do_exec (db, "insert into test (name) values ('test4')");
}
int cols[1];
int handle = sqlite_query (db, "select * from test", cols);
while (sqlite_next_row (handle) == 1) {
for (int i = 0; i < cols[0]; i++)
Print (sqlite_get_col (handle, i));
}
sqlite_free_query (handle);
return (0);
}