-Basic C++ and sql knowledge
-sqlite (Download)
Introduction
sqlite is an embedded sql database engine. Unlike most other sql databases,sqlite does not have a separate server process,but instead reads and writes directly to ordinary disk files. This makes sqlite an easy and good solution to store data for your application.
opening a database
The first thing you need to do,is open a database. If the database does not exist yet,it will be created.
The first argument is the filename,the second is the sqlite3 database handle.
If everything goes right,sqlITE_OKis returned.
Query's
Once the database is opened,you can actually start doing something. The following code shows how:
01
sqlite3_stmt *statement;
02
03
if
(sqlite3_prepare_v2(database,
"CREATE TABLE a (b INTEGER,c INTEGER);"
sqlITE_OK)
04
{
05
int
cols = sqlite3_column_count(statement);
06
result = 0;
07
while
(
true
)
08
09
result = sqlite3_step(statement);
10
11
(result == sqlITE_ROW)
12
13
for
(
col = 0; col < cols; col++)
14
15
string s = (
char
*)sqlite3_column_text(statement,col);
16
//do something with it
17
}
18
}
19
else
20
21
break
;
26
}