ccgus / fmdb

A Cocoa / Objective-C wrapper around SQLite
Other
13.84k stars 2.77k forks source link

Why firstTime is Error, Say no VALUES #472

Open 542604974 opened 8 years ago

542604974 commented 8 years ago

DB Error: 1 "no such table: ZQBasePlayerModel" 2016-03-11 16:20:50.574 SporterMan[14464:268791] DB Query: INSERT INTO ZQBasePlayerModel(name,isPlaying,number) VALUES (?,?,?); 2016-03-11 16:20:50.574 SporterMan[14464:268791] 插入失败

ccgus commented 8 years ago

Check out the section on Reporting Bugs: https://github.com/ccgus/fmdb#reporting-bugs

robertmryan commented 8 years ago

Frankly, this doesn't seem like a FMDB problem, per se, but rather a simple mistake using SQLite. Assuming the problem isn't some simple typo in table name, there a variety of situations that can cause this sort of error. For example, it's common to neglect to copy (or have some problem copying) database from bundle to documents folder, attempt to open the database in documents folder, but when the database is not found in that location, a blank database is automatically created. If that happens, delete app (so blank database is removed) and add error checking/logging in the code that copies the database. You can also use openWithFlags (or equivalent), to make sure SQLite never creates blank database.

But, bottom line, this isn't a FMDB problem, but more likely a general SQLite mistake and a forum like Stack Overflow will be a far better place to ask this question. And make sure to post a MCVE when you post your question (as the code here is not sufficient to diagnose the problem).

542604974 commented 8 years ago

Thank you very much, I published in several BBS discussion, but nobody reply me, so I ask you, now I use another method to solve the storage problem, good hope China's developers also have such a good patience to teach a novice like me, thank you again!

在 2016年3月12日,上午3:36,Rob Ryan notifications@github.com 写道:

Frankly, this doesn't seem like a FMDB problem, per se, but rather a simple mistake using SQLite. Assuming the problem isn't some simple typo in table name, there a variety of situations that can cause this sort of error. For example, it's common to neglect to copy (or have some problem copying) database from bundle to documents folder, attempt to open the database in documents fodlder, but when the database is not found in that location, a blank database is automatically created. If that happens, delete app (so blank database is removed) and add error checking/logging in the code that copies the database. You can also use openWithFlags (or equivalent, to make sure SQLite never creates blank database.

But, bottom line, this isn't a FMDB problem, but more likely a general SQLite mistake and a forum like Stack Overflow will be a far better place to ask this question. And make sure to post a MCVE http://stackoverflow.com/help/mcve when you post your question (as the code here is not sufficient to diagnose the problem).

— Reply to this email directly or view it on GitHub https://github.com/ccgus/fmdb/issues/472#issuecomment-195514731.

robertmryan commented 8 years ago

I've answered questions along these lines a number of times on Stack Overflow, including: