Files
Church-Music/legacy-site/scripts/shell/check-database.sh

44 lines
1.2 KiB
Bash
Raw Normal View History

2026-01-27 18:04:50 -06:00
#!/bin/bash
# Quick verification that PostgreSQL is storing data
echo "Checking PostgreSQL database..."
# Method 1: Direct query
PGPASSWORD=your_password psql -U songlyric_user -d church_songlyric -t -c "
SELECT
'Songs: ' || COUNT(*) as count FROM songs
UNION ALL
SELECT
'Profiles: ' || COUNT(*) FROM profiles
UNION ALL
SELECT
'Profile-Songs: ' || COUNT(*) FROM profile_songs;
" 2>/dev/null || {
echo "Direct PostgreSQL query failed, trying Python..."
# Method 2: Python check
cd /media/pts/Website/Church_HOP_MusicData/backend
source venv/bin/activate
python3 << 'PYTHON'
from postgresql_models import SessionLocal, Song, Profile, ProfileSong
session = SessionLocal()
try:
songs = session.query(Song).count()
profiles = session.query(Profile).count()
profile_songs = session.query(ProfileSong).count()
print(f"✅ PostgreSQL Data:")
print(f" Songs: {songs}")
print(f" Profiles: {profiles}")
print(f" Profile-Songs: {profile_songs}")
if songs > 0:
print(f"\n✅ Data is being stored in PostgreSQL!")
else:
print(f"\n⚠ Warning: No songs found")
finally:
session.close()
PYTHON
}
echo ""
echo "Database check complete."