在Mac上使用sqlite3的内置命令行工具,我在下面运行sql架构(由Lynda.com教程创建)来创建一个sql数据库,数据库bwrss.db
显示为已创建在架构所在的下载文件夹中。然后我运行了本教程提供的代码,该代码应该读取并显示创建db时插入的feed ID
-(void) dispRow:(NSDictionary *) row {
message(@"row %@ [%@]", row [@"title"], row [@"url"]);
}
-(void) testDatabase {
RSSDB *db;
NSString * dbfn = @"bwrss.db";
db = [[RSSDB alloc] initWithRSSDBFilename:dbfn];
message(@"RSSDB version %@", [db getVersion]);
for (NSNumber *n in [db getFeedIDs]) {
NSDictionary *feed = [db getFeedRow:n];
[self dispRow:feed];
}
}
但是,当我运行代码时,它只显示版本号(来自testDatabase方法的第4行),但没有其他内容。它在xCode控制台中显示此错误。
2014-03-21 10:00:51.052 Testbed[1381:a0b] bindSQL: could not prepare statement (no such table: main.feed) CREATE UNIQUE INDEX IF NOT EXISTS feedUrl ON feed(url)
2014-03-21 10:00:51.056 Testbed[1381:a0b] bindSQL: could not prepare statement (no such table: feed) SELECT id FROM feed ORDER BY LOWER(title)
2014-03-21 10:00:51.058 Testbed[1381:a0b] rowFromPreparedQuery: could not get row: no such table: feed
Lynda.com讲师说,如果它只显示版本,则意味着您可能必须从模拟器中删除应用程序以便加载新数据,因为我们在前面的部分中创建了多个版本的应用程序。
错误消息显示,"没有这样的表:feed"但数据库显示为已创建。你能解释一下为什么会这样吗? db文件与项目不在同一个目录中,但我的理解是它不是必须的。
模式
-- bwrss.sql
-- by Bill Weinman - http://bw.org/contact/
-- SQLite database for BW RSS iOS app
-- Copyright 2009-2010 The BearHeart Group LLC
-- This script creates the database tables for the BW RSS application
-- and seeds the feed table with initial records.
DROP TABLE IF EXISTS feed;
DROP TABLE IF EXISTS item;
CREATE TABLE feed (
id INTEGER PRIMARY KEY, -- unique id for this record
url TEXT, -- url for data
title TEXT, -- title of the feed
desc TEXT, -- description of the feed
pubdate TEXT, -- feed last update date/time
stamp TEXT DEFAULT CURRENT_TIMESTAMP
);
CREATE TABLE item (
id INTEGER PRIMARY KEY, -- unique id for this record
feed_id INTEGER, -- feed id
url TEXT, -- url of item
title TEXT, -- title of the item
desc TEXT, -- description of the item
pubdate TEXT, -- publication date/time of this item
stamp TEXT DEFAULT CURRENT_TIMESTAMP
);
CREATE UNIQUE INDEX feedUrl ON feed(url);
INSERT INTO feed (url, title, desc) VALUES (
'http://feeds.feedburner.com/lyndablog',
'lynda.blog',
'the blog of lynda.com'
);
INSERT INTO feed (url, title, desc) VALUES (
'http://feeds.feedburner.com/lyndacom-new-releases',
'lynda.com New Releases',
'lynda.com New Releases RSS Feed.'
);
INSERT INTO feed (url, title, desc) VALUES (
'http://billweinman.wordpress.com/feed/',
'Bill Weinman''s Technology Blog',
'because it''s all about the data'
);
答案 0 :(得分:0)
如果我在ios模拟器中打开,我会遇到同样的问题。
2014-10-23 00:47:34.166 RSS[10465:544566] bindSQL: could not prepare statement (no such table: main.feed) CREATE UNIQUE INDEX IF NOT EXISTS feedUrl ON feed(url)
2014-10-23 00:47:34.167 RSS[10465:544566] bindSQL: could not prepare statement (no such table: feed) SELECT id FROM feed ORDER BY LOWER(title)
2014-10-23 00:47:34.167 RSS[10465:544566] rowFromPreparedQuery: could not get row: no such table: feed
2014-10-23 00:47:34.167 RSS[10465:544566] bindSQL: could not prepare statement (no such table: feed) SELECT id FROM feed ORDER BY LOWER(title)
2014-10-23 00:47:34.167 RSS[10465:544566] rowFromPreparedQuery: could not get row: no such table: feed
2014-10-23 00:47:34.168 RSS[10465:544566] bindSQL: could not prepare statement (no such table: feed) SELECT id FROM feed ORDER BY LOWER(title)
2014-10-23 00:47:34.168 RSS[10465:544566] rowFromPreparedQuery: could not get row: no such table: feed
2014-10-23 00:47:34.169 RSS[10465:544566] bindSQL: could not prepare statement (no such table: feed) SELECT id FROM feed ORDER BY LOWER(title)
2014-10-23 00:47:34.169 RSS[10465:544566] rowFromPreparedQuery: could not get row: no such table: feed
但在正常的设备中工作
也许这就是方法中的原因:
[self bindSQL:[query UTF8String] withVargs:(va_list)dValues.mutableBytes];
错误:
.../BWDB/BWDB.m:276:48: Used type 'va_list' (aka '__builtin_va_list') where arithmetic or pointer type is required