mz mz02005
mz mz02005

Reputation: 9

How to get the query result metadata in sqlite3?

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

Answers (1)

Anto M&#233;ga
Anto M&#233;ga

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

Related Questions