-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathsetup_replit_database.py
More file actions
66 lines (52 loc) · 1.88 KB
/
setup_replit_database.py
File metadata and controls
66 lines (52 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
66
#!/usr/bin/env python3
"""
Quick setup script for Replit PostgreSQL database
"""
import os
import sys
import asyncio
def check_replit_database():
"""Check if Replit database is configured"""
database_url = os.getenv('DATABASE_URL')
if not database_url:
print("❌ DATABASE_URL not found!")
print("\n📝 To set up PostgreSQL in Replit:")
print(" 1. Open the 'Database' tab in the left sidebar")
print(" 2. Click 'Create Database'")
print(" 3. Wait for the database to be created")
print(" 4. Run this script again")
return False
print(f"✅ Found DATABASE_URL: {database_url[:50]}...")
return True
async def setup_database():
"""Run the database setup"""
try:
from database.setup import main as db_setup
success = await db_setup()
return success
except ImportError:
print("❌ Database setup module not found")
print("Installing required dependencies...")
import subprocess
subprocess.run([sys.executable, "-m", "pip", "install", "asyncpg", "psycopg2-binary"])
from database.setup import main as db_setup
success = await db_setup()
return success
def main():
"""Main setup function"""
print("🚀 AgentCraft Replit Database Setup")
print("=" * 40)
# Step 1: Check if database exists
if not check_replit_database():
return False
# Step 2: Run database setup
print("\n🔧 Setting up database schema and default agents...")
success = asyncio.run(setup_database())
if success:
print("\n🎉 Database setup completed successfully!")
print("🚀 You can now start AgentCraft with: python main.py")
else:
print("\n❌ Database setup failed. Check the errors above.")
return success
if __name__ == "__main__":
main()