Skip to content
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

Attempting to write on read only database sqlite #14

Open
eamigo86 opened this issue Jul 12, 2024 · 3 comments
Open

Attempting to write on read only database sqlite #14

eamigo86 opened this issue Jul 12, 2024 · 3 comments

Comments

@eamigo86
Copy link

Hello, first of all congratulations on this great contribution to the community, it was really needed.

I am trying to set up the example Formula project on my Mac and I have followed the Installation section steps to the letter, in addition the suggestion from another ticket to run this command at the project root did not help:
shell chmod 666 ./

NOTE: When trying the same commands in a connection to PostgreSQL, the instructions work fine.

> poetry run env $(cat .env) python src/manage.py migrate
Operations to perform:
  Apply all migrations: admin, auth, contenttypes, django_celery_beat, formula, guardian, sessions
Running migrations:
Traceback (most recent call last):
  File "/Users/eamigo/Documents/Mis Tests/formula/.venv/lib/python3.12/site-packages/django/db/backends/utils.py", line 103, in _execute
    return self.cursor.execute(sql)
           ^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/eamigo/Documents/Mis Tests/formula/.venv/lib/python3.12/site-packages/django/db/backends/sqlite3/base.py", line 325, in execute
    return super().execute(query)
           ^^^^^^^^^^^^^^^^^^^^^^
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 "/Users/eamigo/Documents/Mis Tests/formula/.venv/lib/python3.12/site-packages/django/db/migrations/recorder.py", line 78, in ensure_schema
    editor.create_model(self.Migration)
  File "/Users/eamigo/Documents/Mis Tests/formula/.venv/lib/python3.12/site-packages/django/db/backends/base/schema.py", line 492, in create_model
    self.execute(sql, params or None)
  File "/Users/eamigo/Documents/Mis Tests/formula/.venv/lib/python3.12/site-packages/django/db/backends/base/schema.py", line 202, in execute
    cursor.execute(sql, params)
  File "/Users/eamigo/Documents/Mis Tests/formula/.venv/lib/python3.12/site-packages/django/db/backends/utils.py", line 79, in execute
    return self._execute_with_wrappers(
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/eamigo/Documents/Mis Tests/formula/.venv/lib/python3.12/site-packages/django/db/backends/utils.py", line 92, in _execute_with_wrappers
    return executor(sql, params, many, context)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/eamigo/Documents/Mis Tests/formula/.venv/lib/python3.12/site-packages/django/db/backends/utils.py", line 100, in _execute
    with self.db.wrap_database_errors:
  File "/Users/eamigo/Documents/Mis Tests/formula/.venv/lib/python3.12/site-packages/django/db/utils.py", line 91, in __exit__
    raise dj_exc_value.with_traceback(traceback) from exc_value
  File "/Users/eamigo/Documents/Mis Tests/formula/.venv/lib/python3.12/site-packages/django/db/backends/utils.py", line 103, in _execute
    return self.cursor.execute(sql)
           ^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/eamigo/Documents/Mis Tests/formula/.venv/lib/python3.12/site-packages/django/db/backends/sqlite3/base.py", line 325, in execute
    return super().execute(query)
           ^^^^^^^^^^^^^^^^^^^^^^
django.db.utils.OperationalError: attempt to write a readonly database

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/Users/eamigo/Documents/Mis Tests/formula/src/manage.py", line 22, in <module>
    main()
  File "/Users/eamigo/Documents/Mis Tests/formula/src/manage.py", line 18, in main
    execute_from_command_line(sys.argv)
  File "/Users/eamigo/Documents/Mis Tests/formula/.venv/lib/python3.12/site-packages/django/core/management/__init__.py", line 442, in execute_from_command_line
    utility.execute()
  File "/Users/eamigo/Documents/Mis Tests/formula/.venv/lib/python3.12/site-packages/django/core/management/__init__.py", line 436, in execute
    self.fetch_command(subcommand).run_from_argv(self.argv)
  File "/Users/eamigo/Documents/Mis Tests/formula/.venv/lib/python3.12/site-packages/django/core/management/base.py", line 413, in run_from_argv
    self.execute(*args, **cmd_options)
  File "/Users/eamigo/Documents/Mis Tests/formula/.venv/lib/python3.12/site-packages/django/core/management/base.py", line 459, in execute
    output = self.handle(*args, **options)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/eamigo/Documents/Mis Tests/formula/.venv/lib/python3.12/site-packages/django/core/management/base.py", line 107, in wrapper
    res = handle_func(*args, **kwargs)
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/eamigo/Documents/Mis Tests/formula/.venv/lib/python3.12/site-packages/django/core/management/commands/migrate.py", line 356, in handle
    post_migrate_state = executor.migrate(
                         ^^^^^^^^^^^^^^^^^
  File "/Users/eamigo/Documents/Mis Tests/formula/.venv/lib/python3.12/site-packages/django/db/migrations/executor.py", line 107, in migrate
    self.recorder.ensure_schema()
  File "/Users/eamigo/Documents/Mis Tests/formula/.venv/lib/python3.12/site-packages/django/db/migrations/recorder.py", line 80, in ensure_schema
    raise MigrationSchemaMissing(
django.db.migrations.exceptions.MigrationSchemaMissing: Unable to create the django_migrations table (attempt to write a readonly database)
@bubblegumsoldier
Copy link

I have the same issue

@ShubhamS021
Copy link

Same issue

@bubblegumsoldier
Copy link

I made it work using a workaround and connecting to a local postgres DB

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants