To check if table exists, check if any rows are returned by the following query:
SELECT name FROM sqlite_master WHERE type='table' AND name='your_table_name_here'
To run the query & check if rows exist, here is the code:
sqlite3_stmt *pSelectStatement = NULL;
int iResult = SQLITE_ERROR;
bool ret = false;
iResult = sqlite3_prepare16_v2(m_pDb, query, -1, &pSelectStatement, 0);
if ((iResult == SQLITE_OK) && (pSelectStatement != NULL))
{
iResult = sqlite3_step(pSelectStatement);
//was found?
if (iResult == SQLITE_ROW) {
ret = true;
sqlite3_clear_bindings(pSelectStatement);
sqlite3_reset(pSelectStatement);
}
iResult = sqlite3_finalize(pSelectStatement);
}