user1048396
user1048396

Reputation: 123

Viewing sqlite3 database in iPhone simulator

I have created my database programmatically in my iPhone app in Xcode 4 programmatically. I have also inserted to database and selected required values form it. Everything seems to work fine but I want to check whether the value are getting duplicated or not. I cannot open my database file in Xcode then is there a way to open the database and check the values in it?

Upvotes: 0

Views: 2556

Answers (2)

Anil Kothari
Anil Kothari

Reputation: 7733

There are two ways to do it:-

1) Use SQLite Manager for Firefox browser and then tools--->sqlite Manager-->open database

Now you can run the query

select * from tablename; You can now check the duplicate values manually.

link to install SQLite Manager

https://addons.mozilla.org/en-US/firefox/addon/sqlite-manager/

2) if you want to check the duplicate values through database

-(NSMutableArray *) readFromDatabase:(NSString *)query{
    // Setup the database object
    sqlite3 *database;

    // Init the animals Array
    MutableArray = [[NSMutableArray alloc] init];
    NSString *readCommand=query;

    //readCommand=[readCommand stringByAppendingFormat:@"%@';",patientID];
    // Open the database from the users filessytem
    if(sqlite3_open([databasePath UTF8String], &database) == SQLITE_OK) {
        // Setup the SQL Statement and compile it for faster access
        const char *sqlStatement = [readCommand UTF8String];
        sqlite3_stmt *compiledStatement;
        if(sqlite3_prepare_v2(database, sqlStatement, -1, &compiledStatement, NULL) == SQLITE_OK) {
            // Loop through the results and add them to the feeds array
            while(sqlite3_step(compiledStatement) == SQLITE_ROW) {
                // Read the data from the result row
                [MutableArray addObject:[NSString stringWithUTF8String:(char *)sqlite3_column_text(compiledStatement, 0)]];
            }
        }
        // Release the compiled statement from memory
        sqlite3_finalize(compiledStatement);
    }
    sqlite3_close(database);
    return MutableArray;
}

call this function. and check the returned array values.

Upvotes: 4

beryllium
beryllium

Reputation: 29767

I can suggest to use SQLite plugin for Mozilla Firefox.

https://addons.mozilla.org/en-US/firefox/addon/sqlite-manager/

Upvotes: 1

Related Questions