Fix: Add MySQL 5.6 compatibility and detailed error logging

Added better error handling and MySQL 5.6 support for Windows Server:

1. Enhanced error logging in app.py:
   - Detailed database error messages with error codes
   - Full stack traces logged to console/PM2
   - Error details returned in JSON for debugging

2. Created app-pymysql.py:
   - Alternative version using PyMySQL instead of mysql-connector-python
   - Better compatibility with older MySQL 5.6 servers
   - Handles bit field conversion from bytes to boolean
   - Pure Python implementation (no C extensions)

3. Added requirements-mysql56.txt:
   - PyMySQL 1.1.0 for MySQL 5.6 compatibility
   - Use this on Windows servers with old MySQL

For production Windows servers with MySQL 5.6, use:
  pip install -r requirements-mysql56.txt
  python app-pymysql.py

For debugging 500 errors, check console/PM2 logs for detailed error messages.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
cproudlock
2025-10-24 13:41:52 -04:00
parent f794cde35e
commit a92c2401dd
5 changed files with 173 additions and 6 deletions

23
app.py
View File

@@ -106,15 +106,26 @@ def get_notifications():
})
except mysql.connector.Error as err:
return jsonify({
import traceback
error_details = {
'success': False,
'error': f'Database error: {str(err)}'
}), 500
'error': f'Database error: {str(err)}',
'error_code': err.errno if hasattr(err, 'errno') else None,
'error_msg': err.msg if hasattr(err, 'msg') else str(err),
'traceback': traceback.format_exc()
}
print(f"DATABASE ERROR: {error_details}") # Log to console/PM2
return jsonify(error_details), 500
except Exception as e:
return jsonify({
import traceback
error_details = {
'success': False,
'error': f'Server error: {str(e)}'
}), 500
'error': f'Server error: {str(e)}',
'type': type(e).__name__,
'traceback': traceback.format_exc()
}
print(f"SERVER ERROR: {error_details}") # Log to console/PM2
return jsonify(error_details), 500
# Health check endpoint
@app.route('/health')