I have a sqlite3 table "addresses" like this:
+----+------+--------+
| ID | name | number |
+----+------+--------+
| 1 | John | 413434 |
+----+------+--------+
And i want to populate global vector, which i would be able to use somewhere else and join it with some other data. So far, i have this:
...
#include <sqlite3.h>
using namespace std;
static int callbackDB(void *NotUsed, int argc, char **argv, char **szColName)
{
for(int i = 0; i < argc; i++)
cout << szColName[i] << " = " << argv[i] << endl;
return 0;
}
int main(int argc, char* argv[]) {
vector<vector<string> > table;
for( int i = 0; i < 2; i++ )
table.push_back(std::vector< std::string >());
sqlite3 *db;
char *szErrMsg = 0;
// open database
int rc = sqlite3_open("database.db", &db);
const char *query;
query = "SELECT * FROM addresses";
rc = sqlite3_exec(db, query, callbackDB, 0, &szErrMsg);
return 0;
}
How could i get results in vector or in some other way so that i'll be able to use it easier?