I have an SQLite database, I can open it with SQLite browser, execute queries to it etc. But I can't get any data from it in my Xcode project.
NSString *databaseName = @"dbFile.db";
NSArray *documentPaths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *documentsDir = [documentPaths objectAtIndex:0];
NSString *databasePath = [documentsDir stringByAppendingPathComponent:databaseName];
sqlite3 *database;
if(sqlite3_open([databasePath UTF8String], &database) == SQLITE_OK) {
NSLog(@"db is ok"); // works just fine
const char *sqlStatement = "SELECT table.column FROM table";
sqlite3_stmt *compiledStatement;
if(sqlite3_prepare_v2(database, sqlStatement, -1, &compiledStatement, NULL) == SQLITE_OK) {
NSLog(@"OK"); // nothing happens
}
sqlite3_close(database);
}
The very same query executed from SQLite browser for Mac works just fine.
select col from table, that is, without the table-name prefixed to the column-name?