Last active
December 19, 2015 11:19
-
-
Save tsunokawa/5946757 to your computer and use it in GitHub Desktop.
Couchbaseダンプファイルからキー一覧を取り出すスクリプト
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// Couchbaseダンプファイルからキー一覧を取り出すスクリプト | |
// | |
// 使い方 | |
// php couchbasedumpkeys.php /tmp/bucket-test/node-10.0.0.1%3A8091/data-0000.cbb /tmp/allkey.txt | |
// | |
// 第1引数:ダンプファイル | |
// 第2引数:出力ファイル名 | |
try{ | |
$db = new SQLite3($argv[1], SQLITE3_OPEN_READONLY); | |
$r = $db->query("SELECT key FROM cbb_msg"); | |
while($key = $r->fetchArray()) { | |
$fp = fopen($argv[2], "a"); | |
fwrite($fp, "$key[0]\n"); | |
} | |
$db->close(); | |
fclose($fp); | |
} catch(Exception $e) { | |
echo $e->getMessage(),"\n"; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment