Reputation: 735
I have an application which uses sqlite database. I updated the application and needed to update my database on application launch.
For this I need to check if some column exists in a table. I am not sure how to do it...
I saw PRAGMA table_info(table-name); will return column names but that result is in a table and I am not sure how to read it in Qt.
Upvotes: 0
Views: 1985
Reputation: 180080
PRAGMA table_info returns its data like a normal query, i.e., as if there were a query SELECT cid, name, type, notnull, dflt_value, pk FROM ...
:
query.exec("PRAGMA table_info(MyLittleTable)");
while (query.next()) {
print("column name: ", query.value(1));
}
Upvotes: 4