/* _______ __ __ __ __ \ \ ____ __ __ _______ |__|| | | | |__| ____ ____ / | \ _/ __ \ | | \\_ __ \| || | | | | | / _ \ / \ / | \\ ___/ | | / | | \/| || |__| |__| |( <_> )| | \ \____|__ / \___ >|____/ |__| |__||____/|____/|__| \____/ |___| / =========\/======\/=================================================\/== v0.01 04/JUL/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 20 22:10:24 EDT 2007, v0.01 sdy */ /* g++ 5minutes_2.c -o 5minutes_2 -lsqlite3 */ /* g++ -Wall -O2 -static 5minutes_2.c -o 5minutes_2 -lsqlite3 */ /* SOURCE: http://www.sqlite.org/quickstart.html */ // C++ #include // SQLITE3 #include /* http://www.sqlite.org/capi3ref.html#sqlite3_column_int Results Values From A Query: const void *sqlite3_column_blob(sqlite3_stmt*, int iCol); int sqlite3_column_bytes(sqlite3_stmt*, int iCol); int sqlite3_column_bytes16(sqlite3_stmt*, int iCol); double sqlite3_column_double(sqlite3_stmt*, int iCol); int sqlite3_column_int(sqlite3_stmt*, int iCol); sqlite_int64 sqlite3_column_int64(sqlite3_stmt*, int iCol); const unsigned char *sqlite3_column_text(sqlite3_stmt*, int iCol); const void *sqlite3_column_text16(sqlite3_stmt*, int iCol); int sqlite3_column_type(sqlite3_stmt*, int iCol); sqlite3_value *sqlite3_column_value(sqlite3_stmt*, int iCol); These routines return information about the information in a single column of the current result row of a query. In every case the first argument is a pointer to the SQL statement that is being evaluate (the sqlite_stmt* that was returned from sqlite3_prepare_v2() or one of its variants) and the second argument is the index of the column for which information should be returned. The left-most column has an index of 0. If the SQL statement is not currently point to a valid row, or if the the column index is out of range, the result is undefined. The sqlite3_column_type() routine returns datatype code for the initial data type of the result column. The returned value is one of SQLITE_INTEGER, SQLITE_FLOAT, SQLITE_TEXT, SQLITE_BLOB, or SQLITE_NULL. */ bool headers = true; // GLOBAL VARIABLE, YAY! static int process_row(sqlite3_stmt *stmt, char sep = '|' ) { int ncols = sqlite3_column_count(stmt); int i; // headers is a global var. // If this were an object, we could use an instance var. if ( headers ) { // global! yay. // std::cout << ncols << std::endl; // can be deduced for(i=0; i