android – Methods to examine if a column identify exists in a SQlite database desk (flutter)
[ad_1]
I wish to understand how am i able to examine if a column identify exists in a SQlite database desk in Flutter. I’m utilizing this technique, i wish to know if it’s a good option to do it.
String table_name="faculty"; // INSERT TABLE NAME HERE
String column_name="vote"; // INSERT COLUMN NAME HERE
var knowledge = await db.rawQuery('PRAGMA table_info($table_name);');
bool exists = false;
for (int i = 0; i < knowledge.size; i++) {
print("Accommodates $column_name: ${knowledge[i].containsValue(column_name)}");
if (knowledge[i].containsValue(column_name)) {
exists = true;
}
}
if (exists) {
print("The column $column_name exists!");
} else {
print("The column $column_name does NOT exists");
}
print(knowledge);
[ad_2]