Reputation: 9
Mysql supplies API mysql_fetch_fields to get the query result metadata.
MYSQL_RES *result;
...
auto fieldsNum = mysql_num_fields(result);
auto fields = mysql_fetch_fields(result);
for (size_t i = 0; i < fieldsNum; i++) {
printf("column [%d] name: %.*s\n", i + 1, (int)fields[i].name_length, fields[i].name);
}
Is there any same function in sqlite3?
Upvotes: 0
Views: 84
Reputation: 1
Use
int sqlite3_column_count(sqlite3_stmt *pStmt); // To get number of columns
const char *sqlite3_column_name(sqlite3_stmt*, int N); // To get names of columns
Upvotes: 0