This commit is contained in:
2026-02-04 20:44:02 -05:00
parent 0626e53bfe
commit cd0b011e72

37
dump_db.sh Executable file
View File

@@ -0,0 +1,37 @@
#!/bin/bash
DB_PATH="server/signsync.db"
# Check if sqlite3 is installed
if ! command -v sqlite3 &> /dev/null; then
echo "Error: sqlite3 is not installed or not in PATH."
exit 1
fi
# Check if database file exists
if [ ! -f "$DB_PATH" ]; then
echo "Error: Database file not found at $DB_PATH"
exit 1
fi
# Get list of tables
# sqlite3 .tables returns a list of tables separated by whitespace
tables=$(sqlite3 "$DB_PATH" ".tables")
if [ -z "$tables" ]; then
echo "No tables found in $DB_PATH"
exit 0
fi
echo "Found tables: $tables"
echo "----------------------------------------"
# Loop through tables and print data
for table in $tables; do
echo "Table: $table"
echo "----------------------------------------"
# -header prints column headers, -column aligns output in columns
sqlite3 -header -column "$DB_PATH" "SELECT * FROM $table;"
echo ""
echo "----------------------------------------"
done