[英]What is the best way to collect data for iphone sqlite db
I want to build an iphone app with data pre-filled sqlite db. 我想用数据预填充的sqlite db构建一个iphone应用程序。 But how to fill data in the beginning comes to be a small problem. 但是,如何从一开始就填充数据将成为一个小问题。
My partner and I may both need to access the db and edit data. 我和我的伴侣都可能需要访问数据库并编辑数据。
I thought to build a web interface to edit the data, but my host service only provide PHP+MYSQL solution for me, then if I put the data in MYSQL, how to extract it all into a sqlite db? 我曾想过要构建一个Web界面来编辑数据,但是我的主机服务仅为我提供PHP + MYSQL解决方案,那么如果我将数据放入MYSQL中,如何将其全部提取到sqlite数据库中?
Any good suggestion for my question? 对我的问题有什么好的建议吗? is there any solution for sqlite db remote editing and we can download that sqllite db in the end? sqlite db远程编辑有什么解决方案,我们可以最后下载该sqllite db吗?
i got solution of searching and i done it this is a code to save sqlite data string save in to txt file at application documents directory 我得到了搜索解决方案,我做到了,这是一个将sqlite数据字符串保存到应用程序文档目录中的txt文件中的代码
-(IBAction)creatTxt{
appDelegate = (evernoteAppDelegate *)[[UIApplication sharedApplication] delegate];
NSString *str;
for (int i=0; i<[appDelegate.noteArray count]; i++) {
nottxtobj = [appDelegate.noteArray objectAtIndex:i];
str=[NSString stringWithFormat:@"Title=%@\nDiscription=%@",nottxtobj.noteTitle,nottxtobj.noteDisc];
NSLog(@"data=%@",str);
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *docDir = [paths objectAtIndex:0];
NSString *filename = [docDir stringByAppendingPathComponent:[NSString stringWithFormat:@" %d.txt",nottxtobj.noteID]];
NSError *error = NULL;
BOOL written = [str writeToFile:filename atomically:YES encoding:NSUTF8StringEncoding error:&error];
if (!written)
NSLog(@"write failed, error=%@", error);
}
}
i hope This code is useful for you thank you 我希望这段代码对您有用,谢谢
I don't know about concurrent editing of a SQLite database, but one option you have is to create your database in MySQL then export it as a sql file which you then import into SQLite when you are satisfied with the contents. 我不知道如何同时编辑SQLite数据库,但是您可以选择的一种方法是在MySQL中创建数据库,然后将其导出为sql文件,然后在对内容满意后再导入到SQLite中。
There is one obvious problem with this though, the syntax of the two databases differs slightly. 但是,这有一个明显的问题,两个数据库的语法略有不同。 As long as you aren't using advanced features of MySQL, the majority of the SQL you export from MySQL, using something like the command line tool mysqldump
or the export feature in PHPMyAdmin, should work in SQLite. 只要您不使用MySQL的高级功能,使用命令行工具mysqldump
或PHPMyAdmin中的导出功能之类的东西,从MySQL导出的大多数SQL都应在SQLite中工作。
You would need to prune out the additional data inserted by MySQL for MySQL. 您将需要修剪MySQL为MySQL插入的其他数据。 Luckily people have wanted to do this before and a quick google search brings up a bunch of promising results. 幸运的是,人们以前曾经想这样做,而谷歌的快速搜索带来了很多有希望的结果。
The SQLite site has some options too: http://www.sqlite.org/cvstrac/wiki?p=ConverterTools SQLite网站也有一些选项: http ://www.sqlite.org/cvstrac/wiki?p=ConverterTools
There a bunch of links for software you have to buy, but there is a free shell script about half way down that looks like it might work. 有很多必须购买的软件链接,但是有一个免费的shell脚本,它看起来差不多可以工作了一半。
A free and easy solution: Open a Google Spreadsheet, work on it both, each time you need the result to be inputted into the core data DB just save it as .txt or a .csv and import into the DB. 一个免费,简单的解决方案:每次需要将结果输入到核心数据数据库中时,打开Google Spreadsheet对其进行处理,只需将其另存为.txt或.csv并导入数据库即可。
A plugin for Firefox that you may find useful for the last part: SQLite Manager. Firefox插件,您可能会在最后一部分发现有用:SQLite Manager。
Good luck. 祝好运。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.