commit 6bdce68f3f223c6e01ff0831549d324bc7f78c22 Author: KRZYSZTOF RUDNICKI Date: Wed Oct 16 12:12:13 2024 +0200 feat: bash scripts diff --git a/process_table.sh b/process_table.sh new file mode 100755 index 0000000..553721b --- /dev/null +++ b/process_table.sh @@ -0,0 +1,53 @@ + +#!/bin/bash + +process_table_schema() { + while IFS=$'\t' read -r column_name _ data_type _; do + # Print the column name and data type + echo -e "$column_name\t$data_type" + done < "$1" +} + +input_file="$1" + +# Check if a file is provided as an argument +if [ $# -eq 0 ]; then + echo "Usage: $0 " + exit 1 +fi + +# Process the provided file and skip the first row +first_line=true +process_table_schema "$input_file" | while IFS=$'\t' read -r column_name data_type; do + if [ "$first_line" = true ]; then + first_line=false + continue + fi + case "$data_type" in + "timestamp") + sqlalchemy_type="DateTime" + ;; + "int"|"integer"|"int4") + sqlalchemy_type="Integer" + ;; + "varchar"*|"text") + sqlalchemy_type="String" # handles types like varchar(256) + ;; + "boolean"|"bool") + sqlalchemy_type="Boolean" + ;; + "float"|"float8") + sqlalchemy_type="Float" + ;; + "serial4") + sqlalchemy_type="Integer" + ;; + "numeric"*) + sqlalchemy_type="Numeric" # handles types like numeric(12, 2) + ;; + *) + sqlalchemy_type="UNDEFINED_CHANGE_ME" # default to UNDEFINED_CHANGE_ME if data type is unrecognized + ;; + esac + echo "$column_name = Column($sqlalchemy_type)" +done \ No newline at end of file diff --git a/upgrade.sh b/upgrade.sh new file mode 100755 index 0000000..911ddc2 --- /dev/null +++ b/upgrade.sh @@ -0,0 +1,4 @@ +#!/bin/sh +apt-get -y update && apt-get -y upgrade && apt -y dist-upgrade +apt -y autoremove +aptitude -y update && aptitude -y safe-upgrade && aptitude -y dist-upgrade