sqlite3test.cppGo to the documentation of this file.00001 /* 00002 ** sqlite3test.cpp 00003 ** 00004 ** Published / author: 2006-03-23 / grymse@alhem.net 00005 **/ 00006 00007 /* 00008 Copyright (C) 2006 Anders Hedstrom 00009 00010 This program is free software; you can redistribute it and/or 00011 modify it under the terms of the GNU General Public License 00012 as published by the Free Software Foundation; either version 2 00013 of the License, or (at your option) any later version. 00014 00015 This program is distributed in the hope that it will be useful, 00016 but WITHOUT ANY WARRANTY; without even the implied warranty of 00017 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00018 GNU General Public License for more details. 00019 00020 You should have received a copy of the GNU General Public License 00021 along with this program; if not, write to the Free Software 00022 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 00023 */ 00024 #include <stdio.h> 00025 #include <sqlite3.h> 00026 #include <libsqlitewrapped.h> 00027 00028 00029 int main(int argc,char *argv[]) 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 } |