Fix: Force PyMySQL usage to resolve Coolify deployment error (2059)

This commit is contained in:
Flatlogic Bot 2026-01-29 18:09:02 +00:00
parent 279c717fdd
commit 7b86c4d661
6 changed files with 26 additions and 10 deletions

View File

@ -9,13 +9,10 @@ WORKDIR /app
# Install system dependencies
# WeasyPrint needs: libpango-1.0-0 libpangoft2-1.0-0 libharfbuzz-subset0 libjpeg-dev libopenjp2-7-dev libxcb1
# MySQLclient needs: default-libmysqlclient-dev gcc pkg-config
# MariaDB Client is added to ensure all authentication plugins (like mysql_native_password) are available for MariaDB 11
# PyMySQL does not need libmysqlclient-dev, but we keep basic build tools
RUN apt-get update && apt-get install -y \
gcc \
pkg-config \
default-libmysqlclient-dev \
mariadb-client \
libpango-1.0-0 \
libpangoft2-1.0-0 \
libharfbuzz-subset0 \

View File

@ -0,0 +1,3 @@
import pymysql
pymysql.install_as_MySQLdb()

View File

@ -8,6 +8,9 @@ https://docs.djangoproject.com/en/5.2/howto/deployment/wsgi/
"""
import os
import pymysql
pymysql.install_as_MySQLdb()
from django.core.wsgi import get_wsgi_application

View File

@ -16,6 +16,15 @@ class Command(BaseCommand):
db_conf = settings.DATABASES['default']
self.stdout.write(f"Debug Info - Host: {db_conf.get('HOST')}, Port: {db_conf.get('PORT')}, Name: {db_conf.get('NAME')}, User: {db_conf.get('USER')}")
# DEBUG: Check which MySQLdb is loaded
try:
import MySQLdb
self.stdout.write(f"DEBUG: MySQLdb module is: {MySQLdb}")
if hasattr(MySQLdb, '__file__'):
self.stdout.write(f"DEBUG: MySQLdb location: {MySQLdb.__file__}")
except ImportError:
self.stdout.write("DEBUG: MySQLdb module could NOT be imported.")
self.stdout.write('Waiting for database...')
db_conn = None
for i in range(30): # Retry for 30 seconds

View File

@ -2,6 +2,9 @@
"""Django's command-line utility for administrative tasks."""
import os
import sys
import pymysql
pymysql.install_as_MySQLdb()
def main():

View File

@ -1,5 +1,6 @@
Django==5.2.7
mysqlclient==2.2.7
pymysql
cryptography
python-dotenv==1.1.1
Pillow
weasyprint