AWS App Runner and Django - deterministic=True requires SQLite 3.8.3 or higher

156 Views Asked by At

I'm using AWS App Runner to deploy a django web app, following this guide Deploy and scale Django applications on AWS App Runner. I have no problems deploying, but when I access a page, I'm getting the following error during template rendering.

deterministic=True requires SQLite 3.8.3 or higher

I searched for this error and found this solution, but I don't know how to apply it to AWS App Runner.

Can anyone help me with this or have any other solutions to try?

1

There are 1 best solutions below

0
On

I got the similar issue when running django over App Runner. This issue is due to the sqlite3 database engine in settings.py.

DATABASES = {
    'default': {
        'ENGINE': 'django.db.backends.sqlite3',
        'NAME': BASE_DIR / 'db.sqlite3',
    }
}

Instead of this use sql engine. Obviously you shouldn't use db.sqlite.3 file for database. For that, I have tried to install 'mysqlclient' but got below error. "Exception: Can not find valid pkg-config name. Specify MYSQLCLIENT_CFLAGS and MYSQLCLIENT_LDFLAGS env vars manually". I have tried many solutions but none worked for me. Finally, instead of mysqlclient, I have used 'pymysql' library.

pip install pymysql

settings.py includes,

DATABASES = {
    'default': {
        'ENGINE': 'django.db.backends.mysql',
        'NAME': '<database-name>',
        'USER': '<database-user>',
        'PASSWORD': '<database-password>',
        'HOST': '<database-host>',
        'PORT': '<database-port>',
        'OPTIONS': {
            'sql_mode': 'traditional',
        }
    }
}

And add below lines in init.py file in project root directory (where settings.py file located)

import pymysql
pymysql.install_as_MySQLdb()

For database you can use RDS or any publicly accessible database. Deploy App Runner and look for the logs .