-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsqlite_test.cpp
More file actions
64 lines (53 loc) · 1.55 KB
/
Copy pathsqlite_test.cpp
File metadata and controls
64 lines (53 loc) · 1.55 KB
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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
#include <stdio.h>
#include <iostream>
#include <clocale>
#include <sqlite3.h>
static int callback(void* NotUsed, int argc, char** argv, char** azColName) {
int i;
for (i = 0; i < argc; i++) {
printf("%s = %s\n", azColName[i], argv[i] ? argv[i] : "NULL");
}
printf("\n");
return 0;
}
int main(int argc, char* argv[]) {
setlocale(LC_ALL, "Russian");
sqlite3* db = 0;
char* err = 0;
const char* SQL;
int tp;
int n;
char name[50];
char line[1000];
//tp = sqlite3_open("goods.db", &db);
//if (tp) printf("Opening database fallen. \n");
//else printf("Connection successed. \n");
printf("Press 1 to make sql request.\nPress 2 to open/add db.\nPress 0 to stop running program.\n");
while (1 > 0)
{
scanf_s("%d", &n);
if (n == 1) {
getchar();
fgets(line, 1000, stdin);
SQL = line;
sqlite3_exec(db, SQL, callback, 0, &err);
}
else if (n == 2) {
scanf_s("%s", &name, 35);
tp = sqlite3_open(name, &db);
if (tp) printf("Opening database fallen. \n");
else printf("Connection successed. \n");
}
else if (n == 0) break;
else printf("You entered wrong symbol!\n");
printf("...,,...");
}
//SQL = "CREATE TABLE new (id INTEGER PRIMARY KEY AUTOINCREMENT, name VARCHAR(50), phone VARCHAR(50));";
//sqlite3_exec(db, SQL, callback, 0, &err);
//SQL = "INSERT INTO new (name, phone) VALUES ('Kate', '8906571');";
//sqlite3_exec(db, SQL, callback, 0, &err);
//SQL = "SELECT * FROM new;";
//sqlite3_exec(db, SQL, callback, 0, &err);
sqlite3_close(db);
return 0;
}