From cd0b011e72eddfefe3ba20b56859c52e0c419aba Mon Sep 17 00:00:00 2001 From: jared Date: Wed, 4 Feb 2026 20:44:02 -0500 Subject: [PATCH] dump db --- dump_db.sh | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) create mode 100755 dump_db.sh diff --git a/dump_db.sh b/dump_db.sh new file mode 100755 index 0000000..a417402 --- /dev/null +++ b/dump_db.sh @@ -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