-
-
Save beckyconning/b35ffe3839e3358a34cc83b1dcf0bfee to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
set -e | |
set -o pipefail | |
TABLE_INFO=$(cat) | |
echo "${TABLE_INFO}" | jq -r .name | tr '[:upper:]' '[:lower:]' | while read x ; do printf "create table $x(" ; done | |
echo "${TABLE_INFO}" | jq -r '.columns | .[] | .type = if .type == "offsetdatetime" then "datetime" elif .type == "number" then "decimal" elif .type == "string" then "varchar(255)" elif .type == "boolean" then "boolean" else null end | [.column, .type] | @csv' | tr -d '"' | tr ' ' '_' | tr '[:upper:]' '[:lower:]' | tr ',' ' ' | perl -pe 'chomp if eof' | tr "\n" "," | |
printf ')' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment