mirror of
https://github.com/kuhyx/testsAndMisc.git
synced 2026-07-04 21:23:16 +02:00
- Move all linux_configuration scripts into two semantic categories: - single_use/: scripts run once manually (fresh install, fixes, setup) - periodic_background/: scripts run by systemd timers or daemons - Preserve existing subdirectory structure within each category - Fix lib/common.sh source paths for new directory depths - Fix CONFIG_DIR depth in setup_periodic_system.sh and check_and_enable_services.sh - Update all references in tests, fresh-install/main.sh, nix modules, and docs - Fix check_polling_antipatterns.sh false positives (||, regex |, case patterns, jq strings) - Fix pre-existing mypy exclusion path and type annotations for moved tools/ directory - Rewrite check_polling_antipatterns.sh using awk (no bash regex loops); add require_serial: true
53 lines
1.2 KiB
Bash
Executable File
53 lines
1.2 KiB
Bash
Executable File
#!/bin/bash
|
|
|
|
process_table_schema() {
|
|
while IFS=$'\t' read -r column_name _ data_type _; do
|
|
# Print the column name and data type
|
|
printf '%s\t%s\n' "$column_name" "$data_type"
|
|
done < "$1"
|
|
}
|
|
|
|
input_file="$1"
|
|
|
|
# Check if a file is provided as an argument
|
|
if [ $# -eq 0 ]; then
|
|
echo "Usage: $0 <filename>"
|
|
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
|