Work with databases (DB)

//SQLite ships with the system:
//the C API from libsqlite3
#import <sqlite3.h>

sqlite3 *db;
sqlite3_open("data.db", &db);

sqlite3_stmt *stmt;
sqlite3_prepare_v2(db,
    "select id, name from lines",
    -1, &stmt, NULL);

while (sqlite3_step(stmt) == SQLITE_ROW) {
    int rowId = sqlite3_column_int(stmt, 0);
    const char *name = (const char *)
        sqlite3_column_text(stmt, 1);
    NSLog(@"%d: %s", rowId, name);
}

sqlite3_finalize(stmt);
sqlite3_close(db);