/* _______ __ __ __ __ \ \ ____ __ __ _______ |__|| | | | |__| ____ ____ / | \ _/ __ \ | | \\_ __ \| || | | | | | / _ \ / \ / | \\ ___/ | | / | | \/| || |__| |__| |( <_> )| | \ \____|__ / \___ >|____/ |__| |__||____/|____/|__| \____/ |___| / =========\/======\/=================================================\/== v0.01 03/AUG/2007 (C) Copyright 2007-2007 Scott D. Yelich SOME RIGHTS RESERVED .,-*~'`^`'~*-,._.,-*~'`^`'~*-,._.,-*~'`^`'~*-,._.-*~'`^`'~*-,._.,-*~'`^`'~*-,. LICENSE: Creative Commons Attribution 3.0 License. SEE: http://creativecommons.org/licenses/by/3.0/ Mon Aug 13 23:19:12 EDT 2007, v0.01 sdy This is a *very* simple program written to do test basic sqlite3 functionality. */ // C++ #include #include #include // LOCAL #include "Xql3.h" // Sqlite3 /* This shows how to extend the Xql3 base class to define a callback. This callback also just puts the results into a vector of strings. "h" and "d" were used just to show that the values were not put into or retrieved from _headers and _data. */ class Xqlx : public Xql3 { public: std::vector h; // used to hold reponse headers. std::vector d; // used to hold response data. int callback(std::vector & headers, std::vector & data ) { int header_count = headers.size(); int i; if ( h.size() == 0 && header_count > 0 ) { for(i=0; i 0 ) { for(i=0; i " << sql3.dberrmsg() << std::endl; std::cerr << "Xql3Exception: " << e.code() << " --> " << e.what() << std::endl; return 1; // exit with error .... } // prepare an SQL std::string ... std::stringstream sql_command_ss; sql_command_ss.str(""); sql_command_ss << "DROP TABLE IF EXISTS simple_v2b;"; sql_command_ss << "CREATE TABLE simple_v2b (text,int,time);"; sql_command_ss << "INSERT INTO simple_v2b VALUES('sample v2b text1',1,DATETIME('NOW'));"; sql_command_ss << "UPDATE simple_v2b SET int=int+1 where text='sample v2b text1';"; sql_command_ss << "INSERT INTO simple_v2b VALUES('sample v2b text2',2,DATETIME('NOW'));"; sql_command_ss << "SELECT rowid,* FROM simple_v2b WHERE int<500;"; // clear containers for SQL output ... sql3.h.clear(); sql3.d.clear(); // (2) Also, the program/object would have an "exec" method ... try { sql3.exec(sql_command_ss.str()); } catch (Xql3Exception & e) { std::cerr << "sqlite3_error: " << sql3.dberrcode() << " --> " << sql3.dberrmsg() << std::endl; std::cerr << "Xql3Exception: " << e.code() << " --> " << e.what() << std::endl; return 1; // exit with error .... } // display results, accessing vectors of strings in // this program -- not from the Xql3/Xql4 class object. int header_count = sql3.h.size(); if ( header_count > 0 ) { int i; char sep = '|'; for(i=0; i