-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathtest_remote_connection.py
More file actions
47 lines (37 loc) · 1.3 KB
/
test_remote_connection.py
File metadata and controls
47 lines (37 loc) · 1.3 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
#!/usr/bin/env python3
"""
Simple test script for remote database connection
"""
import sys
import os
# Add the tap_ai directory to Python path
sys.path.insert(0, os.path.dirname(__file__))
try:
# Mock frappe configuration for testing
class MockConf:
def get(self, key, default=None):
# Mock configuration values
config = {
"remote_db_host": "127.0.0.1",
"remote_db_port": 5433,
"remote_db_name": "tap_ai_db",
"remote_db_user": "tap_ai_user",
"remote_db_password": "tap_ai_password"
}
return config.get(key, default)
import frappe
frappe.conf = MockConf()
# Test the remote database connection
from tap_ai.utils.remote_db import get_remote_connection, execute_remote_query
print("Testing remote database connection...")
# Try to get connection
conn = get_remote_connection()
print("✅ Connection established successfully")
# Try a simple query
results = execute_remote_query("SELECT 1 as test")
print(f"✅ Query executed successfully: {results}")
print("🎉 All tests passed!")
except Exception as e:
print(f"❌ Test failed: {e}")
import traceback
traceback.print_exc()