iphone app でsqliteを利用したい

アプリケーションの結果を保存したい。
調べたところ、coredataというものがiphoneフレームワークには備わっているらしい。

ただ、なんとなく敷居が高そうなので、まずはsqliteで実装してみる。

ターミナルでsqliteを起動する。

sqlite3 database.sqlite

コンソールに戻る場合はquit。

.quit

まず、データベースファイルを作成する。

sqlite3 srGunDB.sqlite
SQLite version 3.6.12
Enter ".help" for instructions
Enter SQL statements terminated with a ";"

.database とコマンドを打つ。

sqlite> .database
seq  name             file                                                      
---  ---------------  ----------------------------------------------------------
0    main             /Users/brackpanda/srGunDB.sqlite 
create table category(
   'id' integer,
   'title' text,
   'date' text
);

create table detail(
    'categoryId' integer,
    'no' integer,
    'speed' text,
    'speedLabel' text,
    'distance' text,
    'distanceLabel' text
);

.schemaと打つことで確認することができる

.schema

これで、テーブルの準備は完了。