I would like to print the contents of the sql table and for this reason I would like to get the column name from the table. One of the solutions I came across was the following:
SELECT sql FROM sqlite_master WHERE tbl_name = 'table_name' AND type = 'table'
But it seems that I will have to analyze the results.
Another suggestion was to use:
PRAGMA table_info(table_name);
but the next sqlite page suggests not using this: http://www.sqlite.org/pragma.html#pragma_full_column_names
Is there any way to achieve this. The syntax will also be used.
The above decisions were taken from here
c , API SQLite C. prepare_v2, , sqlite3_column_name, .
c
PRAGMA table_info(table-name);, - ( ).
PRAGMA table_info(table-name);
int sqlite3_get_table( sqlite3 *db, /* An open database */ const char *zSql, /* SQL to be evaluated */ char ***pazResult, /* Results of the query */ int *pnRow, /* Number of result rows written here */ int *pnColumn, /* Number of result columns written here */ char **pzErrmsg /* Error msg written here */ );
c/++, sqlite3_get_table (db, query, result, nrow, ncol, errmsg);
select * ;
[0], [1]...... .