summaryrefslogtreecommitdiffstats
path: root/data/strokes.awk
diff options
context:
space:
mode:
Diffstat (limited to 'data/strokes.awk')
-rw-r--r--data/strokes.awk29
1 files changed, 29 insertions, 0 deletions
diff --git a/data/strokes.awk b/data/strokes.awk
new file mode 100644
index 0000000..5c61062
--- /dev/null
+++ b/data/strokes.awk
@@ -0,0 +1,29 @@
+#!/usr/bin/awk
+
+BEGIN {
+ # Begin a transaction
+ print "BEGIN TRANSACTION;"
+
+ # Create english table
+ print "CREATE TABLE IF NOT EXISTS \"strokes\" ( " \
+ "\"character\" TEXT NOT NULL," \
+ "\"sequence\" INTEGER NOT NULL," \
+ "\"strokes\" TEXT NOT NULL," \
+ "\"token\" INTEGER NOT NULL DEFAULT (0)" \
+ ");";
+
+ # Create desc table
+ print "CREATE TABLE IF NOT EXISTS desc (name TEXT PRIMARY KEY, value TEXT);";
+ print "INSERT OR IGNORE INTO desc VALUES ('version', '1.2.0');";
+}
+
+ # Insert data into english table
+NF == 4 {
+ printf "INSERT INTO strokes (\"character\", \"sequence\", strokes, token) VALUES (\"%s\", %d, \"%s\", %d);\n", $1, $2, $3, $4;
+ }
+
+ #quit sqlite3
+END {
+ # Commit the transcation
+ print "COMMIT;"
+}