-
Notifications
You must be signed in to change notification settings - Fork 1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Error when executing the demo-applicaion: attempt to write a readonly database #2
Comments
I have difficulty to reproduce this problem. That is using sqlite as well.
I can login, and I can modify a person. (Saving does not seem to work, but when I reload the page, I can see that it was saved. but that is another topic/bug...) This thread on Stackoverflow might give ideas: https://stackoverflow.com/questions/40703228/python-sqlite3-operationalerror-attempt-to-write-a-readonly-database
for me the permissions are like this:
Perhaps you are missing the x for others?
|
Hi, Perhaps it would be good to add a note at the end of the get-script that the commands need to be executed as root (although I think it would be better to being able to run the server without root for security reasons. |
You are right, we don't want the server to run as root. I am just wondering, why the sqlite database was readonly: Perhaps you had another open connection to the database? Or a connection was not closed properly? sqlite can only have one concurrent write connection. |
Not sure if I am too late here, but the problem comes from the following: A process accessing the database in write-mode (which is necessary at login time because session data is written to the database) needs to have write permission to the directory where the sqlite-file is located in. This is because sqlite creates a lock-file in the directory when the accessing process is writing to the file. This is necessary to handle concurrent writes in sqlite (see https://sqlite.org/lockingv3.html). |
Hi,
I executed the get-script and then execute the source and manage.py commands.
When trying to login in the browser I am faced with an "attempt to write a readonly database" error.
I'm using Ubuntu 20.04.1 LTS 64-bit
I tried to adapt the permissions of the sqlite-file with chmod 777 filename but the error still persisted.
Stacktrace is the following:
`C(.venv) joachim@joachim-Aspire-S3:/home/django/basxconnect_demo$ python manage.py runserver
Watching for file changes with StatReloader
Performing system checks...
System check identified no issues (0 silenced).
December 21, 2020 - 09:02:38
Django version 3.1.4, using settings 'basxconnect_demo.settings.dev'
Starting development server at http://127.0.0.1:8000/
Quit the server with CONTROL-C.
Internal Server Error: /bread/login
Traceback (most recent call last):
File "/home/django/basxconnect_demo/.venv/lib/python3.8/site-packages/dynamic_preferences/managers.py", line 212, in load_from_db
db_pref = db_prefs[preference.identifier()]
KeyError: 'general__sender_letterhead'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/home/django/basxconnect_demo/.venv/lib/python3.8/site-packages/django/db/models/query.py", line 573, in get_or_create
return self.get(**kwargs), False
File "/home/django/basxconnect_demo/.venv/lib/python3.8/site-packages/django/db/models/query.py", line 429, in get
raise self.model.DoesNotExist(
dynamic_preferences.models.GlobalPreferenceModel.DoesNotExist: GlobalPreferenceModel matching query does not exist.
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/home/django/basxconnect_demo/.venv/lib/python3.8/site-packages/django/db/backends/utils.py", line 84, in _execute
return self.cursor.execute(sql, params)
File "/home/django/basxconnect_demo/.venv/lib/python3.8/site-packages/django/db/backends/sqlite3/base.py", line 413, in execute
return Database.Cursor.execute(self, query, params)
sqlite3.OperationalError: attempt to write a readonly database
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "/home/django/basxconnect_demo/.venv/lib/python3.8/site-packages/django/core/handlers/exception.py", line 47, in inner
response = get_response(request)
File "/home/django/basxconnect_demo/.venv/lib/python3.8/site-packages/django/core/handlers/base.py", line 202, in _get_response
response = response.render()
File "/home/django/basxconnect_demo/.venv/lib/python3.8/site-packages/django/template/response.py", line 105, in render
self.content = self.rendered_content
File "/home/django/basxconnect_demo/.venv/lib/python3.8/site-packages/django/template/response.py", line 83, in rendered_content
return template.render(context, self._request)
File "/home/django/basxconnect_demo/.venv/lib/python3.8/site-packages/django/template/backends/django.py", line 61, in render
return self.template.render(context)
File "/home/django/basxconnect_demo/.venv/lib/python3.8/site-packages/django/template/base.py", line 168, in render
with context.bind_template(self):
File "/usr/lib/python3.8/contextlib.py", line 113, in enter
return next(self.gen)
File "/home/django/basxconnect_demo/.venv/lib/python3.8/site-packages/django/template/context.py", line 244, in bind_template
updates.update(processor(self.request))
File "/home/django/basxconnect_demo/.venv/lib/python3.8/site-packages/dynamic_preferences/processors.py", line 10, in global_preferences
return {'global_preferences': manager.all()}
File "/home/django/basxconnect_demo/.venv/lib/python3.8/site-packages/dynamic_preferences/managers.py", line 203, in all
a.update(self.load_from_db(cache=True))
File "/home/django/basxconnect_demo/.venv/lib/python3.8/site-packages/dynamic_preferences/managers.py", line 214, in load_from_db
db_pref = self.create_db_pref(
File "/home/django/basxconnect_demo/.venv/lib/python3.8/site-packages/dynamic_preferences/managers.py", line 179, in create_db_pref
db_pref, created = self.model.objects.get_or_create(**kwargs)
File "/home/django/basxconnect_demo/.venv/lib/python3.8/site-packages/django/db/models/manager.py", line 85, in manager_method
return getattr(self.get_queryset(), name)(*args, **kwargs)
File "/home/django/basxconnect_demo/.venv/lib/python3.8/site-packages/django/db/models/query.py", line 576, in get_or_create
return self._create_object_from_params(kwargs, params)
File "/home/django/basxconnect_demo/.venv/lib/python3.8/site-packages/django/db/models/query.py", line 610, in _create_object_from_params
obj = self.create(**params)
File "/home/django/basxconnect_demo/.venv/lib/python3.8/site-packages/django/db/models/query.py", line 447, in create
obj.save(force_insert=True, using=self.db)
File "/home/django/basxconnect_demo/.venv/lib/python3.8/site-packages/dynamic_preferences/models.py", line 67, in save
super(BasePreferenceModel, self).save(**kwargs)
File "/home/django/basxconnect_demo/.venv/lib/python3.8/site-packages/django/db/models/base.py", line 753, in save
self.save_base(using=using, force_insert=force_insert,
File "/home/django/basxconnect_demo/.venv/lib/python3.8/site-packages/django/db/models/base.py", line 790, in save_base
updated = self._save_table(
File "/home/django/basxconnect_demo/.venv/lib/python3.8/site-packages/django/db/models/base.py", line 895, in _save_table
results = self._do_insert(cls._base_manager, using, fields, returning_fields, raw)
File "/home/django/basxconnect_demo/.venv/lib/python3.8/site-packages/django/db/models/base.py", line 933, in _do_insert
return manager._insert(
File "/home/django/basxconnect_demo/.venv/lib/python3.8/site-packages/django/db/models/manager.py", line 85, in manager_method
return getattr(self.get_queryset(), name)(*args, **kwargs)
File "/home/django/basxconnect_demo/.venv/lib/python3.8/site-packages/django/db/models/query.py", line 1254, in _insert
return query.get_compiler(using=using).execute_sql(returning_fields)
File "/home/django/basxconnect_demo/.venv/lib/python3.8/site-packages/django/db/models/sql/compiler.py", line 1397, in execute_sql
cursor.execute(sql, params)
File "/home/django/basxconnect_demo/.venv/lib/python3.8/site-packages/django/db/backends/utils.py", line 98, in execute
return super().execute(sql, params)
File "/home/django/basxconnect_demo/.venv/lib/python3.8/site-packages/django/db/backends/utils.py", line 66, in execute
return self._execute_with_wrappers(sql, params, many=False, executor=self._execute)
File "/home/django/basxconnect_demo/.venv/lib/python3.8/site-packages/django/db/backends/utils.py", line 75, in _execute_with_wrappers
return executor(sql, params, many, context)
File "/home/django/basxconnect_demo/.venv/lib/python3.8/site-packages/django/db/backends/utils.py", line 84, in _execute
return self.cursor.execute(sql, params)
File "/home/django/basxconnect_demo/.venv/lib/python3.8/site-packages/django/db/utils.py", line 90, in exit
raise dj_exc_value.with_traceback(traceback) from exc_value
File "/home/django/basxconnect_demo/.venv/lib/python3.8/site-packages/django/db/backends/utils.py", line 84, in _execute
return self.cursor.execute(sql, params)
File "/home/django/basxconnect_demo/.venv/lib/python3.8/site-packages/django/db/backends/sqlite3/base.py", line 413, in execute
return Database.Cursor.execute(self, query, params)
django.db.utils.OperationalError: attempt to write a readonly database
[21/Dec/2020 09:02:44] "GET /bread/login?next=/ HTTP/1.1" 500 237484
Internal Server Error: /bread/login
Traceback (most recent call last):
File "/home/django/basxconnect_demo/.venv/lib/python3.8/site-packages/dynamic_preferences/managers.py", line 212, in load_from_db
db_pref = db_prefs[preference.identifier()]
KeyError: 'general__sender_letterhead'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/home/django/basxconnect_demo/.venv/lib/python3.8/site-packages/django/db/models/query.py", line 573, in get_or_create
return self.get(**kwargs), False
File "/home/django/basxconnect_demo/.venv/lib/python3.8/site-packages/django/db/models/query.py", line 429, in get
raise self.model.DoesNotExist(
dynamic_preferences.models.GlobalPreferenceModel.DoesNotExist: GlobalPreferenceModel matching query does not exist.
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/home/django/basxconnect_demo/.venv/lib/python3.8/site-packages/django/db/backends/utils.py", line 84, in _execute
return self.cursor.execute(sql, params)
File "/home/django/basxconnect_demo/.venv/lib/python3.8/site-packages/django/db/backends/sqlite3/base.py", line 413, in execute
return Database.Cursor.execute(self, query, params)
sqlite3.OperationalError: attempt to write a readonly database
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "/home/django/basxconnect_demo/.venv/lib/python3.8/site-packages/django/core/handlers/exception.py", line 47, in inner
response = get_response(request)
File "/home/django/basxconnect_demo/.venv/lib/python3.8/site-packages/django/core/handlers/base.py", line 202, in _get_response
response = response.render()
File "/home/django/basxconnect_demo/.venv/lib/python3.8/site-packages/django/template/response.py", line 105, in render
self.content = self.rendered_content
File "/home/django/basxconnect_demo/.venv/lib/python3.8/site-packages/django/template/response.py", line 83, in rendered_content
return template.render(context, self._request)
File "/home/django/basxconnect_demo/.venv/lib/python3.8/site-packages/django/template/backends/django.py", line 61, in render
return self.template.render(context)
File "/home/django/basxconnect_demo/.venv/lib/python3.8/site-packages/django/template/base.py", line 168, in render
with context.bind_template(self):
File "/usr/lib/python3.8/contextlib.py", line 113, in enter
return next(self.gen)
File "/home/django/basxconnect_demo/.venv/lib/python3.8/site-packages/django/template/context.py", line 244, in bind_template
updates.update(processor(self.request))
File "/home/django/basxconnect_demo/.venv/lib/python3.8/site-packages/dynamic_preferences/processors.py", line 10, in global_preferences
return {'global_preferences': manager.all()}
File "/home/django/basxconnect_demo/.venv/lib/python3.8/site-packages/dynamic_preferences/managers.py", line 203, in all
a.update(self.load_from_db(cache=True))
File "/home/django/basxconnect_demo/.venv/lib/python3.8/site-packages/dynamic_preferences/managers.py", line 214, in load_from_db
db_pref = self.create_db_pref(
File "/home/django/basxconnect_demo/.venv/lib/python3.8/site-packages/dynamic_preferences/managers.py", line 179, in create_db_pref
db_pref, created = self.model.objects.get_or_create(**kwargs)
File "/home/django/basxconnect_demo/.venv/lib/python3.8/site-packages/django/db/models/manager.py", line 85, in manager_method
return getattr(self.get_queryset(), name)(*args, **kwargs)
File "/home/django/basxconnect_demo/.venv/lib/python3.8/site-packages/django/db/models/query.py", line 576, in get_or_create
return self._create_object_from_params(kwargs, params)
File "/home/django/basxconnect_demo/.venv/lib/python3.8/site-packages/django/db/models/query.py", line 610, in _create_object_from_params
obj = self.create(**params)
File "/home/django/basxconnect_demo/.venv/lib/python3.8/site-packages/django/db/models/query.py", line 447, in create
obj.save(force_insert=True, using=self.db)
File "/home/django/basxconnect_demo/.venv/lib/python3.8/site-packages/dynamic_preferences/models.py", line 67, in save
super(BasePreferenceModel, self).save(**kwargs)
File "/home/django/basxconnect_demo/.venv/lib/python3.8/site-packages/django/db/models/base.py", line 753, in save
self.save_base(using=using, force_insert=force_insert,
File "/home/django/basxconnect_demo/.venv/lib/python3.8/site-packages/django/db/models/base.py", line 790, in save_base
updated = self._save_table(
File "/home/django/basxconnect_demo/.venv/lib/python3.8/site-packages/django/db/models/base.py", line 895, in _save_table
results = self._do_insert(cls._base_manager, using, fields, returning_fields, raw)
File "/home/django/basxconnect_demo/.venv/lib/python3.8/site-packages/django/db/models/base.py", line 933, in _do_insert
return manager._insert(
File "/home/django/basxconnect_demo/.venv/lib/python3.8/site-packages/django/db/models/manager.py", line 85, in manager_method
return getattr(self.get_queryset(), name)(*args, **kwargs)
File "/home/django/basxconnect_demo/.venv/lib/python3.8/site-packages/django/db/models/query.py", line 1254, in _insert
return query.get_compiler(using=using).execute_sql(returning_fields)
File "/home/django/basxconnect_demo/.venv/lib/python3.8/site-packages/django/db/models/sql/compiler.py", line 1397, in execute_sql
cursor.execute(sql, params)
File "/home/django/basxconnect_demo/.venv/lib/python3.8/site-packages/django/db/backends/utils.py", line 98, in execute
return super().execute(sql, params)
File "/home/django/basxconnect_demo/.venv/lib/python3.8/site-packages/django/db/backends/utils.py", line 66, in execute
return self._execute_with_wrappers(sql, params, many=False, executor=self._execute)
File "/home/django/basxconnect_demo/.venv/lib/python3.8/site-packages/django/db/backends/utils.py", line 75, in _execute_with_wrappers
return executor(sql, params, many, context)
File "/home/django/basxconnect_demo/.venv/lib/python3.8/site-packages/django/db/backends/utils.py", line 84, in _execute
return self.cursor.execute(sql, params)
File "/home/django/basxconnect_demo/.venv/lib/python3.8/site-packages/django/db/utils.py", line 90, in exit
raise dj_exc_value.with_traceback(traceback) from exc_value
File "/home/django/basxconnect_demo/.venv/lib/python3.8/site-packages/django/db/backends/utils.py", line 84, in _execute
return self.cursor.execute(sql, params)
File "/home/django/basxconnect_demo/.venv/lib/python3.8/site-packages/django/db/backends/sqlite3/base.py", line 413, in execute
return Database.Cursor.execute(self, query, params)
django.db.utils.OperationalError: attempt to write a readonly database
[21/Dec/2020 09:02:47] "GET /bread/login?next=/ HTTP/1.1" 500 237621`
The text was updated successfully, but these errors were encountered: