-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsqlite-view.sh
More file actions
37 lines (34 loc) · 1.17 KB
/
sqlite-view.sh
File metadata and controls
37 lines (34 loc) · 1.17 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
#!/bin/bash
# SQLite Database Viewer Script
# Usage: ./sqlite-view.sh [users|complaints|chats|all]
DB="/Users/ntggamer1/Desktop/Project/college_complaints.db"
case "${1:-all}" in
users)
echo "=== USERS TABLE ==="
sqlite3 "$DB" -header -column "SELECT id, username, name, type FROM users;"
;;
complaints)
echo "=== COMPLAINTS TABLE ==="
sqlite3 "$DB" -header -column "SELECT id, student_id, title, category, status FROM complaints;"
;;
chats)
echo "=== CHATS TABLE ==="
sqlite3 "$DB" -header -column "SELECT id, complaint_id, sender_name, sender_role FROM chats LIMIT 10;"
;;
all)
echo "=== DATABASE OVERVIEW ==="
echo ""
echo "Users:"
sqlite3 "$DB" -header -column "SELECT username, name, type FROM users;"
echo ""
echo "Complaints:"
sqlite3 "$DB" -header -column "SELECT id, student_id, title, status FROM complaints;"
echo ""
echo "Chats:"
echo "Total messages: $(sqlite3 "$DB" "SELECT COUNT(*) FROM chats;")"
;;
*)
echo "Usage: ./sqlite-view.sh [users|complaints|chats|all]"
exit 1
;;
esac