This commit is contained in:
Executable
+32
@@ -0,0 +1,32 @@
|
||||
|
||||
import os
|
||||
import psycopg2
|
||||
from psycopg2.extras import RealDictCursor
|
||||
|
||||
def list_live():
|
||||
try:
|
||||
db_url = os.environ.get('DATABASE_URL', 'postgresql://suggestbet:SuGGesT2026SecuRe@localhost:15432/boilerplate_db')
|
||||
conn = psycopg2.connect(db_url, cursor_factory=RealDictCursor)
|
||||
cursor = conn.cursor()
|
||||
|
||||
cursor.execute("""
|
||||
SELECT m.id, ht.name as home, at.name as away
|
||||
FROM live_matches m
|
||||
JOIN teams ht ON m.home_team_id = ht.id
|
||||
JOIN teams at ON m.away_team_id = at.id
|
||||
LIMIT 10
|
||||
""")
|
||||
rows = cursor.fetchall()
|
||||
|
||||
print("Live Matches in DB:")
|
||||
for r in rows:
|
||||
print(f"ID: {r['id']} | {r['home']} vs {r['away']}")
|
||||
|
||||
cursor.execute("SELECT COUNT(*) FROM live_matches")
|
||||
print(f"\nTotal Live Matches: {cursor.fetchone()['count']}")
|
||||
|
||||
except Exception as e:
|
||||
print(e)
|
||||
|
||||
if __name__ == "__main__":
|
||||
list_live()
|
||||
Reference in New Issue
Block a user