• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: sqlite iphone question....
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: sqlite iphone question....


  • Subject: Re: sqlite iphone question....
  • From: Dave DeLong <email@hidden>
  • Date: Fri, 23 Jan 2009 11:32:51 -0700

I would REALLY recommend using some sort of wrapper class for sqlite, instead of using the functions yourself. Why put yourself through the pain when someone else already has?

Here are the ones I would recommend:
http://th30z.netsons.org/2008/11/objective-c-sqlite-wrapper/
http://code.google.com/p/flycode/

Dave

On Jan 23, 2009, at 11:12 AM, James Cicenia wrote:

Hmmm,,,

OK I read the docs a bit.. and now I am confused. This code snippet was basically copied and pasted from the sqlbook example.
It works when I run it in the simulator.


Mine .. .does get past the open database, but doesn't really get past the select.

I also don't quite understand where I should set or copy mydatabase.sqlite. It is in the Resource group and in the target already.

Confused
James Cicenia


On Jan 23, 2009, at 11:39 AM, Keary Suska wrote:


On Jan 23, 2009, at 10:30 AM, James Cicenia wrote:

- (void)initializeDatabase {
	NSMutableArray *items = [[NSMutableArray alloc] init];
	self.produceItems = items;
	[items release];

// The database is stored in the application bundle.
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *documentsDirectory = [paths objectAtIndex:0];
NSString *path = [documentsDirectory stringByAppendingPathComponent:@"whatsfresh.sqlite"];

// Open the database. The database was prepared outside the application.
if (sqlite3_open([path UTF8String], &database) == SQLITE_OK) {
NSLog(@"Open Database");
// Get the primary key for all produce.
const char *sql = "SELECT id FROM Item";
sqlite3_stmt *statement;
// Preparing a statement compiles the SQL query into a byte- code program in the SQLite library.
// The third parameter is either the length of the SQL string or -1 to read up to the first null terminator.
if (sqlite3_prepare_v2(database, sql, -1, &statement, NULL) == SQLITE_OK) {


NEVER GETS PAST THIS IF. I have queried the database and the data is in there?!


Working with files in the app bundle like this may be a non-no. At least, it is for Mac OS X, and the emulator might have this issue. To know for sure, put the database file into the "sandbox" and see if it behaves better there.

HTH,

Keary Suska
Esoteritech, Inc.
"Demystifying technology for your home or business"


_______________________________________________

Cocoa-dev mailing list (email@hidden)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden

_______________________________________________

Cocoa-dev mailing list (email@hidden)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden


References: 
 >sqlite iphone question.... (From: James Cicenia <email@hidden>)
 >Re: sqlite iphone question.... (From: Keary Suska <email@hidden>)
 >Re: sqlite iphone question.... (From: James Cicenia <email@hidden>)

  • Prev by Date: NSNumberFormatter setFormat: in 10.3.9
  • Next by Date: Start traces with CrashReporter
  • Previous by thread: Re: sqlite iphone question....
  • Next by thread: Re: sqlite iphone question....
  • Index(es):
    • Date
    • Thread