On 03/22/2017 05:58 AM, Ausama Majeed wrote:
Hello guys,
I am trying to do a connection between a database created with Sqlite and
my application in ns3. the sqlite engine is installed on ubuntu 16.04
machine and the output is enabled with ns3.26. I cann't do a simple select
query from ns3, however it working through the terminal.
I install sqlite-autoconf-3170000 as API to deal with the database.
the BD is opened successfully in the fallowing code:
sqlite3 *db;
int rc;
char *error = 0;
rc = sqlite3_open("/home/mypc/Desktop/ns-3.26/ns-3.26/testDB.db", &db);
if (rc) {
cerr << "Error opening SQLite3 database: " << sqlite3_errmsg(db) <<
endl << endl;
sqlite3_close(db);
return 1;
} else {
cout << "\n Successfully connected to the database \n";
int n = 0;
cin >> n;
// Print this info
cout << GARIComposeAlgo(db, error, n);
cout << "\nclose the db\n";
sqlite3_close(db);
}
But, select query returns only the table field headers instead of the
required record in the following code
As expected, I think. If your SELECT statement returns N rows of M
columns, get_table() gives you an array of (N+1)*M nul-terminated
strings. The first M strings in the array are the column headers, the
next M are the first row of results, and so on.
https://sqlite.org/c3ref/free_table.html
Dan.
string Query = " select ActorId, ActorType from ActorInfo where ID =" +
tempProcess.str() +";";
char **results = NULL;
int rows, columns;
const char *sqlSelect = Query.c_str();
int rc;
rc = sqlite3_get_table(db, sqlSelect, &results, &rows, &columns,
&error);
if (rc != SQLITE_OK) {
cerr << "Error executing SQLite3 query: " << sqlite3_errmsg(db) <<
endl << endl;
sqlite3_free(error);
}
else {
for (int i= 0; i<4; i++) {cout << results[i]<< endl;}
}
Could anyone advice me what could the problem and how to check it, solve it
please.
Thanks
_______________________________________________
sqlite-users mailing list
sqlite-users@mailinglists.sqlite.org
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users
_______________________________________________
sqlite-users mailing list
sqlite-users@mailinglists.sqlite.org
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users