jayanth-2005 commited on
Commit
158b568
·
verified ·
1 Parent(s): 99942f8

Update src/utils/database.py

Browse files
Files changed (1) hide show
  1. src/utils/database.py +2 -6
src/utils/database.py CHANGED
@@ -1,10 +1,8 @@
1
  import sqlite3
2
- import os
3
  from datetime import datetime
4
 
5
- # ✅ Setup database path relative to current file
6
- BASE_DIR = os.path.dirname(os.path.abspath(__file__))
7
- DB_PATH = os.path.join(BASE_DIR, "..", "data", "bharat_play.db")
8
 
9
  def get_db_connection():
10
  return sqlite3.connect(DB_PATH)
@@ -47,14 +45,12 @@ def get_user_submissions(username):
47
  conn = get_db_connection()
48
  c = conn.cursor()
49
  try:
50
- # Check if the table exists
51
  c.execute('''SELECT name FROM sqlite_master
52
  WHERE type='table' AND name='submissions';''')
53
  if not c.fetchone():
54
  print("Submissions table does not exist")
55
  return []
56
 
57
- # Get user submissions
58
  c.execute('''SELECT * FROM submissions
59
  WHERE name = ?
60
  ORDER BY timestamp DESC''', (username,))
 
1
  import sqlite3
 
2
  from datetime import datetime
3
 
4
+ # ✅ Use Hugging Face writable directory
5
+ DB_PATH = "/data/bharat_play.db"
 
6
 
7
  def get_db_connection():
8
  return sqlite3.connect(DB_PATH)
 
45
  conn = get_db_connection()
46
  c = conn.cursor()
47
  try:
 
48
  c.execute('''SELECT name FROM sqlite_master
49
  WHERE type='table' AND name='submissions';''')
50
  if not c.fetchone():
51
  print("Submissions table does not exist")
52
  return []
53
 
 
54
  c.execute('''SELECT * FROM submissions
55
  WHERE name = ?
56
  ORDER BY timestamp DESC''', (username,))