i create table in sqlite manager
, export desktop , name db_fo_dic.sqlite
, , can open db_fo_dic.sqlite
use sqlite manager
, copy db_fo_dic.sqlite
xcode project catalogue, try open sqlite file fmdb
, failed:
nsstring *path = [[nsbundle mainbundle] pathforresource:@"db_fo_dic" oftype:@"sqlite"];
fmdatabase *db = [fmdatabase databasewithpath:path];
the result info : 2016-08-01 19:22:34.955 test_sqlite[15380:425242] fmdatabase <fmdatabase: 0x7ff589c38f10> not open.
this location path of sqlite: /users/youpude/library/developer/coresimulator/devices/87d0245a-47f7-4741-81b2-209625cb3c5e/data/containers/bundle/application/47b3ad1f-c08e-4e34-8858-494a95fb9ea5/test_sqlite.app/db_fo_dic.sqlite
8 hours go through, find method solve problem finally.
#import "fmdatabasequeue.h" static fmdatabasequeue *_queue;
in - (void)viewdidload
:
_queue = [fmdatabasequeue databasequeuewithpath:path];
and can query database:
[_queue indatabase:^(fmdatabase *db) { fmresultset *result = [db executequery:@"select * dic_content limit 10;"]; while ([result next]) { nsstring *str = [result stringforcolumn:@"tit"]; nslog(@"%@",str); } }];
i use method replace previous method.
Comments
Post a Comment