Created
April 16, 2015 14:50
-
-
Save kmtr/bd0241340d79fbb2e309 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
package main | |
// for Qiita version 2.3.1 (2030100) | |
import ( | |
"database/sql" | |
"io/ioutil" | |
"log" | |
"os/user" | |
"strconv" | |
_ "github.com/mattn/go-sqlite3" | |
) | |
func main() { | |
usr, err := user.Current() | |
dir := usr.HomeDir | |
dbfilePath := "/Library/Containers/com.qiita.Kobito/Data/Library/Kobito/Kobito.db" | |
db, err := sql.Open("sqlite3", dir+dbfilePath) | |
if err != nil { | |
log.Fatal(err) | |
} | |
SELECT_MD := `select ZRAW_BODY from ZITEM` | |
r, err := db.Query(SELECT_MD) | |
if err != nil { | |
log.Fatal(err) | |
} | |
defer r.Close() | |
index := 0 | |
for r.Next() { | |
var raw string | |
if err := r.Scan(&raw); err != nil { | |
log.Fatal(err) | |
} | |
ioutil.WriteFile(strconv.Itoa(index)+".md", []byte(raw), 0666) | |
index++ | |
} | |
if err := r.Err(); err != nil { | |
log.Fatal(err) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment