sqlite prepare statement error - no such table

后端 未结 3 686
天命终不由人
天命终不由人 2021-01-14 19:45

I\'m having some difficulty with my sqlite prepare statement. I get an error saying my table does not exist, although I\'ve checked in multiple places for it, and it does ex

3条回答
  •  甜味超标
    2021-01-14 20:29

    Not enough rep to comment on Jack's post, but that helped me.

    In my case, I had mistyped my path for resource extension:

    // Wrong
    NSString *sqLiteDb = [[NSBundle mainBundle] pathForResource:@"productList"
                                                             ofType:@"sqlite3"];
    
    // Should have been (added db ext)
    NSString *sqLiteDb = [[NSBundle mainBundle] pathForResource:@"productList"
                                                         ofType:@"db"];
    

    I would always get past the:

    if (sqlite3_open([sqLiteDb UTF8String], &_database) == SQLITE_OK))
    

    because it was automatically creating a db file for me.

提交回复
热议问题