$ sqlite3 mydb.sqlite3 sqlite> .separator "\t" sqlite> .import mydata.tsv mytable
データベースを使っていると、よくcsvファイルと相互に変換したくなります。MySQLやPostgreSQLでは標準でcsvのインポート/エクスポートができるので、SQLiteでも出来るだろうという事で調べてみました。 結論から言うとSQLiteで使えるCSVのインポート/エクスポートは制約が強くて使い辛いです。というのも、カラムの文字列内にセパレータ(標準ではカンマ)が含まれている場合は、クォートされていても、セパレータとして認識されてしまい、正常なcsvとして扱われないからです。(例えば”Hi, Nice to meet you.”は2カラムとして扱われます。) ちなみにSQLite標準のインポート/エクスポートは以下のように行います。 # 標準で以下のようにインポート/エクスポートできるが、セパレータが上手くパースされない .mode csv table_name # エクスポート S
I'm trying to bulk load a lot of data ( 5.5 million rows ) into an SQLite database file. Loading via INSERTs seems to be far too slow, so I'm trying to use the sqlite3 command line tool and the .import command. It works perfectly if I enter the commands by hand, but I can't for the life of me work out how to automate it from a script ( .bat file or python script; I'm working on a Windows machine )
リリース、障害情報などのサービスのお知らせ
最新の人気エントリーの配信
処理を実行中です
j次のブックマーク
k前のブックマーク
lあとで読む
eコメント一覧を開く
oページを開く