# MEMEX - Eldritch Oneliner

# Eldritch Oneliner

I needed to insert a dictionary into a SQL database.

    (echo -n "INSERT INTO REF_DICTIONARY (TYPE, WORD, DEFINITION) VALUES"; (jq < kaikki.org-dictionary-English.json 'select( .pos=="noun" or .pos=="verb" or .pos=="name" or .pos=="adj" ) | {pos: .pos, word: .word, meaning: .senses[].glosses[]} | select( .meaning | length<128 ) | [.pos, .word, .meaning] | @csv' -r | sed 's/\(.*\)/(\1),/g;' | tr -d "\n")) | sed 's/,$/;/' > dict.sql

For loading wikipedia titles

    (echo "INSERT IGNORE INTO REF_WIKI_TITLE(NAME) VALUES";(grep -e "^[a-zA-Z0-9_']\+$" enwiki-20210701-all-titles-in-ns0 | sed 's/\(.*\)/("\1"),/g') | tr -d \\n) | sed 's/,$/;/' > wiki.sql