You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何修复AWS Linux环境下Django的URIs not supported错误

Fixing django.db.utils.NotSupportedError: URIs not supported in Django 1.11.7 + SQLite 3.7.17

Let's break down why this error is happening and how to fix it, step by step:

Root Cause

Django 1.11's SQLite backend disables URI support by default—even though your SQLite version (3.7.17) does support URIs (SQLite added this feature back in version 3.7.7). The error pops up when you've used a URI-formatted path (like file:///path/to/db.sqlite3) in your NAME database setting, but haven't told Django to enable URI parsing for SQLite.


Solution 1: Enable URI Support in Database Config

If you specifically need to use a URI (for example, to work with an in-memory database, read-only mode, or other URI-specific features), update your settings.py DATABASES config to add the uri flag under OPTIONS:

import os

DATABASES = {
    'default': {
        'ENGINE': 'django.db.backends.sqlite3',
        'NAME': 'file:///path/to/your/database.sqlite3',  # Your URI-formatted path
        'OPTIONS': {
            'uri': True,  # This tells Django to parse the NAME value as an SQLite URI
        },
    }
}

This will force Django to handle the NAME field as an SQLite URI instead of a regular file path.


If you don't need URI-specific functionality, the simplest and most reliable fix is to use a standard absolute or relative file path for your SQLite database. This avoids URI parsing entirely:

import os
from django.conf import settings

DATABASES = {
    'default': {
        'ENGINE': 'django.db.backends.sqlite3',
        'NAME': os.path.join(settings.BASE_DIR, 'db.sqlite3'),  # Relative to your project root
        # Alternatively, use an absolute path like '/var/www/yourproject/db.sqlite3'
    }
}

This is the standard Django setup for SQLite and will work without any extra configuration.


Quick Validation

Just to confirm: your SQLite version (3.7.17) is well above the 3.7.7 minimum required for URI support, so either solution will work depending on your needs.

内容的提问来源于stack exchange,提问作者iPaul

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.21 07:53:24