li6185377 / LKDBHelper-SQLite-ORM

全自动的插入,查询,更新,删除, an automatic database operation thread-safe and not afraid of recursive deadlock
MIT License
1.21k stars 288 forks source link

请问大批量数据怎么导入?事务我一直插入不对 #73

Closed zhoupIT closed 8 years ago

zhoupIT commented 8 years ago

LKDBHelper* globalHelper = [IDSginUserTest getUsingLKDBHelper]; [globalHelper executeDB:^(FMDatabase db) { [db beginTransaction]; IDSginUserTest signuser = [[IDSginUserTest alloc] init]; for (NSDictionary *dict in responseObject) { signuser = [IDSginUserTest personWithDict:dict]; [globalHelper insertToDB:signuser]; }

                    BOOL insertSucceed = [globalHelper insertWhenNotExists:signuser];
                    //insert fail
                    if(insertSucceed == NO)
                        [db rollback];
                    else
                        [db commit];
                }];

这样一直连表都没有生成,我直接插入,速度就太慢了.请问一下,这是为什么啊,我模仿的demo的

li6185377 commented 8 years ago

可能在事务状态下 没法创建表, 你可以先保存一条数据后,再进行事务操作

Humein commented 7 years ago

怎么先保存一条数据? 我这样做了,可还是不行

li6185377 commented 7 years ago

哦 你没有执行 结束事务吧 要commit 下