Skip to content

Instantly share code, notes, and snippets.

@katsuhide
Created May 31, 2013 19:37
Show Gist options
  • Save katsuhide/5687441 to your computer and use it in GitHub Desktop.
Save katsuhide/5687441 to your computer and use it in GitHub Desktop.
SQLite
// DB設定情報
NSString *databaseName = @"main.db";
NSString *path = @"/tmp";
NSString *databasePath = [path stringByAppendingPathComponent:databaseName];
FMDatabase *db = [FMDatabase databaseWithPath:databasePath];
// Query
NSString *sql = @"select hoge1, hoge2 participants from hoge;";
// Open DB
[db open];
// Execute Query
FMResultSet *results = [db executeQuery:sql];
// Output
while ([results next]) {
NSLog(@"%@, %@", [results stringForColumn:@"hoge1"], [results stringForColumn:@"hoge2"]);
}
// Release result set
[results close];
// Close DB
[db close];
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment