summaryrefslogtreecommitdiff
path: root/neue-Kategorie
diff options
context:
space:
mode:
authorErich Eckner <git@eckner.net>2019-10-13 20:22:23 +0200
committerErich Eckner <git@eckner.net>2019-10-13 20:22:23 +0200
commitaadf74caa0f2ec402aba5529e58a8a1c2d30c64e (patch)
tree117022341bb9050c5b1eaff173f870991459e913 /neue-Kategorie
parentf68f3c9f08aaffde2e7ad54ffbcac98e9d6e33e9 (diff)
downloadSchraubendatenbank-aadf74caa0f2ec402aba5529e58a8a1c2d30c64e.tar.xz
neue-Kategorie neu
Diffstat (limited to 'neue-Kategorie')
-rwxr-xr-xneue-Kategorie30
1 files changed, 30 insertions, 0 deletions
diff --git a/neue-Kategorie b/neue-Kategorie
new file mode 100755
index 0000000..8de4e1b
--- /dev/null
+++ b/neue-Kategorie
@@ -0,0 +1,30 @@
+#!/bin/bash
+
+if [ $# -ne 2 ]; then
+ >&2 echo "$0"' $Kategorie $Eintrag'
+ exit 1
+fi
+
+declare -A Kategorien
+Kategorien['Kopf']='Koepfe'
+Kategorien['Gewindetyp']='Gewindetypen'
+Kategorien['Material']='Materialien'
+
+if [ -z "${Kategorien["$1"]}" ]; then
+ >&2 printf 'unbekannte Kategorie %s, ich kenne:\n' "${1}"
+ >&2 printf '%s\n' "${!Kategorien[@]}"
+ exit 2
+fi
+
+{
+ printf 'INSERT IGNORE INTO `%s`' "${Kategorien["$1"]}"
+ printf ' (`name`)'
+ printf ' VALUES ('
+ printf 'FROM_BASE64("'
+ printf '%s' "$2" \
+ | base64 -w0
+ printf '")'
+ printf ');\n'
+} \
+| mysql \
+&& echo 'ok'