Spaces:
Runtime error
Runtime error
Commit ·
4e819c6
1
Parent(s): 76bf02c
fixed db config
Browse files- pms_server/settings.py +5 -4
- utils/test_db.py +16 -0
pms_server/settings.py
CHANGED
|
@@ -143,15 +143,16 @@ if AIVEN_CA_CERT:
|
|
| 143 |
ca_file.write(AIVEN_CA_CERT)
|
| 144 |
ca_file.flush()
|
| 145 |
ca_file.close()
|
|
|
|
| 146 |
ssl_options = {
|
| 147 |
-
"
|
| 148 |
-
"
|
| 149 |
-
"
|
| 150 |
}
|
| 151 |
else:
|
| 152 |
# If no certificate provided, disable SSL verification (not recommended for production)
|
| 153 |
ssl_options = {
|
| 154 |
-
"
|
| 155 |
}
|
| 156 |
|
| 157 |
# Validate database configuration
|
|
|
|
| 143 |
ca_file.write(AIVEN_CA_CERT)
|
| 144 |
ca_file.flush()
|
| 145 |
ca_file.close()
|
| 146 |
+
# PyMySQL SSL configuration
|
| 147 |
ssl_options = {
|
| 148 |
+
"ssl_ca": ca_file.name,
|
| 149 |
+
"ssl_verify_cert": True,
|
| 150 |
+
"ssl_verify_identity": False
|
| 151 |
}
|
| 152 |
else:
|
| 153 |
# If no certificate provided, disable SSL verification (not recommended for production)
|
| 154 |
ssl_options = {
|
| 155 |
+
"ssl_disabled": True
|
| 156 |
}
|
| 157 |
|
| 158 |
# Validate database configuration
|
utils/test_db.py
CHANGED
|
@@ -57,6 +57,22 @@ def test_database_connection():
|
|
| 57 |
|
| 58 |
return False
|
| 59 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 60 |
except ImportError as e:
|
| 61 |
print(f"❌ Django import error: {e}")
|
| 62 |
print(" This might be due to missing dependencies or configuration issues.")
|
|
|
|
| 57 |
|
| 58 |
return False
|
| 59 |
|
| 60 |
+
except Exception as e:
|
| 61 |
+
error_msg = str(e)
|
| 62 |
+
|
| 63 |
+
if "unexpected keyword argument" in error_msg and "ssl" in error_msg.lower():
|
| 64 |
+
print("❌ SSL Configuration error:")
|
| 65 |
+
print(" PyMySQL SSL configuration issue. This has been fixed.")
|
| 66 |
+
print(" Please redeploy with the updated configuration.")
|
| 67 |
+
elif "Connection.__init__()" in error_msg:
|
| 68 |
+
print("❌ Database connection parameter error:")
|
| 69 |
+
print(" Invalid connection parameters for PyMySQL.")
|
| 70 |
+
print(" This is likely an SSL configuration issue that has been fixed.")
|
| 71 |
+
else:
|
| 72 |
+
print(f"❌ Unexpected error: {error_msg}")
|
| 73 |
+
|
| 74 |
+
return False
|
| 75 |
+
|
| 76 |
except ImportError as e:
|
| 77 |
print(f"❌ Django import error: {e}")
|
| 78 |
print(" This might be due to missing dependencies or configuration issues.")
|