summaryrefslogtreecommitdiff
path: root/main.go
diff options
context:
space:
mode:
Diffstat (limited to 'main.go')
-rw-r--r--main.go28
1 files changed, 2 insertions, 26 deletions
diff --git a/main.go b/main.go
index 7306df2..fa0cd20 100644
--- a/main.go
+++ b/main.go
@@ -3,7 +3,6 @@
package main
import (
- "database/sql"
"log"
_ "github.com/mattn/go-sqlite3"
@@ -13,32 +12,9 @@ const rawDictionary = "/home/david/work/french-wiktionary-flashcards/raw-wiktext
const dictionary = "/home/david/work/french-wiktionary-flashcards/raw-wiktextract-data.sqlite3"
func main() {
- db, err := sql.Open("sqlite3", dictionary)
+ _, err := setupDatabase()
if err != nil {
- log.Fatalf("opening DB '%s': %s", dictionary, err)
- }
- defer db.Close()
-
- _, err = db.Exec("create table IF NOT EXISTS words (word text not null, definition text);")
- if err != nil {
- log.Fatalf("creating table: %s", err)
- }
-
- _, err = db.Exec("PRAGMA synchronous = OFF;")
- if err != nil {
- log.Fatalf("setting risky writes: %s", err)
- }
-
- row := db.QueryRow(`SELECT count(*) as count from words`)
- var count int
- err = row.Scan(&count)
- if err != nil {
- log.Fatalf("counting rows: %s", err)
- }
- if count == 0 {
- if err = readDictionary(db); err != nil {
- log.Fatalf("failed to prepare dictionary: %s", err)
- }
+ log.Fatalf("setting up database: %s", err)
}
}