forked from abaykan/scout
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinit_db.py
More file actions
executable file
·65 lines (55 loc) · 1.88 KB
/
init_db.py
File metadata and controls
executable file
·65 lines (55 loc) · 1.88 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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
#!/usr/bin/env python3
"""
Database Initialization Script for S.C.O.U.T
Run this script to create the necessary database tables
"""
import sys
from src.db import Database
def initialize_database():
"""Initialize the database by creating all tables"""
print("🔧 Initializing S.C.O.U.T Database...")
try:
db = Database()
if db.connect():
db.initialize_database()
print("✅ Database tables created successfully!")
db.disconnect()
return True
else:
print("❌ Failed to connect to database")
return False
except Exception as e:
print(f"❌ Error initializing database: {e}")
return False
def test_database_connection():
"""Test database connection"""
print("🔌 Testing database connection...")
try:
db = Database()
if db.connect():
print("✅ Database connection successful!")
db.disconnect()
return True
else:
print("❌ Database connection failed")
return False
except Exception as e:
print(f"❌ Connection error: {e}")
return False
if __name__ == "__main__":
print("S.C.O.U.T Database Setup")
print("=" * 40)
# Test connection first
if not test_database_connection():
print("\nPlease check your database configuration in config.json")
print("Make sure MySQL is running and credentials are correct")
sys.exit(1)
# Initialize database
print("\n" + "=" * 40)
if initialize_database():
print("\n🎉 Database setup completed successfully!")
print("\nNext steps:")
print("1. Run: python main.py (to start monitoring)")
else:
print("\n❌ Database setup failed")
sys.exit(1)