Reputation: 433
in my Django project in Linux machine (in AWS) I'm using:
I've created virtual environment for my project and all dependencies are installed perfectly there. For the database I'm using sqlite3. See below for the version details.
>>>import sqlite3
>>>sqlite3.version
'2.6.0'
>>>sqlite3.sqlite_version_info
(3, 7, 17)
In settings.py the DATABASES section is as below:
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.sqlite3',
'NAME': os.path.join(BASE_DIR, 'db.sqlite3'),
}
}
While running runserver I am getting one exception as sqlite3.NotSupportedError: URIs not supported which is generating an error django.db.utils.NotSupportedError: URIs not supported, that I am not able to fix.
I have gone through the posts like djangoproject.com and google.forum, but still not able to understand the reason for this error. I also tried to do python manage.py makemigrations but same error coming for that also.
Note: In windows machine this my project is running fine.
Please see the traceback below:
# python manage.py runserver
Performing system checks...
System check identified no issues (0 silenced).
Unhandled exception in thread started by <function check_errors.
<locals>.wrapper at 0x7f07ff09c2f0>
Traceback (most recent call last):
File "/tech/poc/env/lib/python3.5/site-packages/django/db/backends/base/base.py", line 213, in ensure_connection
self.connect()
File "/tech/poc/env/lib/python3.5/site- packages/django/db/backends/base/base.py", line 189, in connect
self.connection = self.get_new_connection(conn_params)
File "/tech/poc/env/lib/python3.5/site-packages/django/db/backends/sqlite3/base.py", line 198, in get_new_connection
conn = Database.connect(**conn_params)
sqlite3.NotSupportedError: URIs not supported
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "/tech/poc/env/lib/python3.5/site-packages/django/utils/autoreload.py", line 228, in wrapper
fn(*args, **kwargs)
File "/tech/poc/env/lib/python3.5/site-packages/django/core/management/commands/runserver.py", line 128, in inner_run
self.check_migrations()
File "/tech/poc/env/lib/python3.5/site-packages/django/core/management/base.py", line 422, in check_migrations
executor = MigrationExecutor(connections[DEFAULT_DB_ALIAS])
File "/tech/poc/env/lib/python3.5/site-packages/django/db/migrations/executor.py", line 20, in __init__
self.loader = MigrationLoader(self.connection)
File "/tech/poc/env/lib/python3.5/site-packages/django/db/migrations/loader.py", line 52, in __init__
self.build_graph()
File "/tech/poc/env/lib/python3.5/site-packages/django/db/migrations/loader.py", line 209, in build_graph
self.applied_migrations = recorder.applied_migrations()
File "/tech/poc/env/lib/python3.5/site-packages/django/db/migrations/recorder.py", line 65, in applied_migrations
self.ensure_schema()
File "/tech/poc/env/lib/python3.5/site-packages/django/db/migrations/recorder.py", line 52, in ensure_schema
if self.Migration._meta.db_table in self.connection.introspection.table_names(self.connection.cursor()):
File "/tech/poc/env/lib/python3.5/site-packages/django/db/backends/base/base.py", line 254, in cursor
return self._cursor()
File "/tech/poc/env/lib/python3.5/site-packages/django/db/backends/base/base.py", line 229, in _cursor
self.ensure_connection()
File "/tech/poc/env/lib/python3.5/site-packages/django/db/backends/base/base.py", line 213, in ensure_connection
self.connect()
File "/tech/poc/env/lib/python3.5/site-packages/django/db/utils.py", line 94, in __exit__
six.reraise(dj_exc_type, dj_exc_value, traceback)
File "/tech/poc/env/lib/python3.5/site-packages/django/utils/six.py", line 685, in reraise
raise value.with_traceback(tb)
File "/tech/poc/env/lib/python3.5/site-packages/django/db/backends/base/base.py", line 213, in ensure_connection
self.connect()
File "/tech/poc/env/lib/python3.5/site-packages/django/db/backends/base/base.py", line 189, in connect
self.connection = self.get_new_connection(conn_params)
File "/tech/poc/env/lib/python3.5/site-packages/django/db/backends/sqlite3/base.py", line 198, in get_new_connection
conn = Database.connect(**conn_params)
django.db.utils.NotSupportedError: URIs not supported
Please help to understand and fix this error. There is no related posts in stack for this issue nor I have found anything relevant in google.
Upvotes: 7
Views: 11728
Reputation: 162
I was facing the same issue while connecting to Postgresql on Ubuntu. I downgraded the Django version from the latest to 3.2.15. This resolved the problem for me. I hope this helps.
Upvotes: 0
Reputation: 187
I got a similar problem. Turns out Django 2.1 is incompatible with sqlite 3.6.20. Downgrade to version 2.0.x and you should be good. The issue has been raised and is labelled "Closed bug- wontfix" here
Upvotes: 2
Reputation: 37
1.You have to check sqlite3 version first. It should be 3.X
My configuration is Python 3.7
, django 2.1.7
and sqlite3
.
You can check sqlite3 version as below:
>>import sqlite3
>>sqlite3.version
'2.6.0'
>>> sqlite3.sqlite_version_info
(3, 6, 20)`
"/usr/local/lib/python3.7/site-packages/django/db/backends/sqlite3/base.py"
Look for line" kwargs.update({'check_same_thread': False, 'uri': False})
If 'uri' is True, then change it to False as root.
After code change, reboot your machine and run python runserver migrate
This should resolve your issue.Also, you can try changing the DATABASE['NAME'] with hardcoded db.sqli3 file name in the SETTINGS.py
file.
Upvotes: 1