File: table.awk

package info (click to toggle)
ibus-libpinyin 1.16.5-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 5,980 kB
  • sloc: cpp: 21,874; sh: 5,754; ansic: 1,095; python: 1,062; makefile: 512; xml: 490; awk: 32; sed: 16
file content (32 lines) | stat: -rw-r--r-- 823 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
#!/usr/bin/awk

BEGIN {
    # Begin a transaction
    print "BEGIN TRANSACTION;"

    # Create english table
    print "CREATE TABLE IF NOT EXISTS phrases ( "      \
        "id INTEGER PRIMARY KEY NOT NULL,"             \
        "tabkeys TEXT NOT NULL,"                       \
        "phrase TEXT NOT NULL,"                        \
        "freq INTEGER NOT NULL DEFAULT (10)"           \
        ");";

    # 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.12.0');";

    id = 1;
}

# Insert data into phrases table
NF == 4 {
    printf "INSERT INTO phrases (id, tabkeys, phrase) VALUES (%d, '%s', '%s');\n", id, $3, $1;
    id++;
}

#quit sqlite3
END {
    # Commit the transcation
    print "COMMIT;"
}