File size: 1,742 Bytes
a7f57dc
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
#!/usr/bin/env python3
"""
Deploy local database to production environment.
This script copies the local SQLite database to the production location.
"""

import os
import shutil
import sys

def main():
    """Copy local database to production location"""
    
    # Get the current directory (this will be /app in production)
    base_dir = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
    local_db = os.path.join(base_dir, "users.db")
    
    print(f"Database location: {local_db}")
    
    # Check if database exists
    if not os.path.exists(local_db):
        print(f"Error: Database not found at {local_db}")
        return 1
    
    # Get database info
    size = os.path.getsize(local_db)
    print(f"Database size: {size} bytes")
    
    # Verify database structure
    import sqlite3
    try:
        conn = sqlite3.connect(local_db)
        cursor = conn.cursor()
        
        # Check tables
        cursor.execute("SELECT name FROM sqlite_master WHERE type='table';")
        tables = cursor.fetchall()
        print(f"Tables found: {[table[0] for table in tables]}")
        
        # Check user count
        cursor.execute("SELECT COUNT(*) FROM users")
        user_count = cursor.fetchone()[0]
        print(f"Users in database: {user_count}")
        
        # Check prediction count
        cursor.execute("SELECT COUNT(*) FROM predictions")
        prediction_count = cursor.fetchone()[0]
        print(f"Predictions in database: {prediction_count}")
        
        conn.close()
        print("Database verification successful!")
        return 0
        
    except Exception as e:
        print(f"Error verifying database: {e}")
        return 1

if __name__ == "__main__":
    sys.exit(main())