Forums  +  C++ and Sockets  +  C++ and SQL: MySQL, sqlite, ODBC  +  Miscellaneous Projects
Logo
~Database~
~ C++ ~
~Contact~

sqlite3test.cpp File Reference

#include <stdio.h>
#include <sqlite3.h>
#include <libsqlitewrapped.h>

Include dependency graph for sqlite3test.cpp:

Go to the source code of this file.


Functions

int main (int argc, char *argv[])

Function Documentation

int main ( int  argc,
char *  argv[] 
)

Definition at line 29 of file sqlite3test.cpp.

References Query::execute(), Query::fetch_row(), Query::free_result(), Query::get_result(), Query::getstr(), and Query::getval().

00030 {
00031         Database::Mutex mutex; // not really necessary here at all
00032         StderrLog log;
00033         Database db(mutex, "test3.db", &log);
00034         Query q(db);
00035 
00036         // create a test3 table
00037         q.execute("create table test3 ( num integer, name string )");
00038 
00039         // fill test3 with some data
00040         q.execute("insert into test3 values(1, 'Anders')");
00041         q.execute("insert into test3 values(2, 'Grymse')");
00042 
00043         // retrieve data
00044         q.get_result("select * from test3");
00045         while (q.fetch_row())
00046         {
00047                 long num = q.getval();
00048                 std::string name = q.getstr();
00049                 printf("#%ld: %s\n", num, name.c_str());
00050         }
00051         q.free_result();
00052 
00053         //
00054         return 0;
00055 }

Page, code, and content Copyright (C) 2006 by Anders Hedström