Last active
July 24, 2017 05:20
-
-
Save htakeuchi/933064d05c2178da9da3 to your computer and use it in GitHub Desktop.
KobitoのデータベースからMarkdownを抽出
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
# -*- coding: utf-8 -*- | |
require 'rubygems' | |
require 'sqlite3' | |
# ~/Library/Containers/com.qiita.Kobito/Data/Library/Kobito/Kobito.db | |
KOBITO_DB = "/tmp/Kobito.db" | |
EXPORT_PATH = "/tmp/export" | |
COLUMNS = %w(ZTITLE ZRAW_BODY) | |
db = SQLite3::Database.new(KOBITO_DB) | |
db.execute("select #{COLUMNS.join(',')} from ZITEM where ZIN_TRASH IS NULL") do |note| | |
file = %!#{EXPORT_PATH}/#{note[0].gsub(/(\/|\.\.)/, '_')}.md! | |
open(file, 'w') {|f| f.write note[1]} | |
puts file | |
end | |
db.close |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment