Spaces:
Build error
Build error
Update app.py
Browse files
app.py
CHANGED
|
@@ -20,11 +20,10 @@ import secrets
|
|
| 20 |
ASR_MODEL = "base" # Smaller Whisper model
|
| 21 |
NLU_MODEL = "facebook/blenderbot-400M-distill" # Smaller conversation model
|
| 22 |
|
| 23 |
-
# Database configuration
|
| 24 |
-
# Database configuration
|
| 25 |
DB_CONFIG = {
|
| 26 |
"host": "hopper.proxy.rlwy.net",
|
| 27 |
-
"port": 16751,
|
| 28 |
"user": "root",
|
| 29 |
"password": "svLvVDyJwyvWsAxTAEkrMPqkzLBkLMrD",
|
| 30 |
"database": "railway",
|
|
@@ -34,8 +33,15 @@ DB_CONFIG = {
|
|
| 34 |
|
| 35 |
# Create connection pool
|
| 36 |
try:
|
|
|
|
| 37 |
cnx_pool = mysql.connector.pooling.MySQLConnectionPool(**DB_CONFIG)
|
| 38 |
print("Database connection pool created successfully")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 39 |
except Exception as e:
|
| 40 |
print(f"Error creating database pool: {e}")
|
| 41 |
# Use in-memory dictionary as fallback
|
|
|
|
| 20 |
ASR_MODEL = "base" # Smaller Whisper model
|
| 21 |
NLU_MODEL = "facebook/blenderbot-400M-distill" # Smaller conversation model
|
| 22 |
|
| 23 |
+
# Database configuration - use this to replace the DB_CONFIG section in app.py
|
|
|
|
| 24 |
DB_CONFIG = {
|
| 25 |
"host": "hopper.proxy.rlwy.net",
|
| 26 |
+
"port": 16751, # Make sure port is included as an integer
|
| 27 |
"user": "root",
|
| 28 |
"password": "svLvVDyJwyvWsAxTAEkrMPqkzLBkLMrD",
|
| 29 |
"database": "railway",
|
|
|
|
| 33 |
|
| 34 |
# Create connection pool
|
| 35 |
try:
|
| 36 |
+
print(f"Attempting to connect to MySQL at {DB_CONFIG['host']}:{DB_CONFIG['port']}...")
|
| 37 |
cnx_pool = mysql.connector.pooling.MySQLConnectionPool(**DB_CONFIG)
|
| 38 |
print("Database connection pool created successfully")
|
| 39 |
+
|
| 40 |
+
# Test the connection by getting one
|
| 41 |
+
test_conn = cnx_pool.get_connection()
|
| 42 |
+
if test_conn.is_connected():
|
| 43 |
+
print(f"Successfully connected to {DB_CONFIG['database']} database")
|
| 44 |
+
test_conn.close()
|
| 45 |
except Exception as e:
|
| 46 |
print(f"Error creating database pool: {e}")
|
| 47 |
# Use in-memory dictionary as fallback
|