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

sqlite3.OperationalError: table sqlite_master may not be modified #45

Open
PanosDine opened this issue Feb 1, 2023 · 0 comments
Open

Comments

@PanosDine
Copy link

PanosDine commented Feb 1, 2023

I get the following error when I try to use the db-to-sqlite command to export my postgres db into a .db file:
sqlite3.OperationalError: table sqlite_master may not be modified

I'm using db-to-sqlite 1.4, sqlite-utils 3.30, and Python 3.10.8. I installed db-to-sqlite with pip install 'db-to-sqlite[postgresql]'.

My command is something like:
db-to-sqlite "postgresql://localhost/my_db" my_exported_db.db --all --skip=django_migrations

Traceback:

File "/Users/user/.virtualenvs/myproject/bin/db-to-sqlite", line 8, in <module>
    sys.exit(cli())
  File "/Users/user/.virtualenvs/myproject/lib/python3.10/site-packages/click/core.py", line 1130, in __call__
    return self.main(*args, **kwargs)
  File "/Users/user/.virtualenvs/myproject/lib/python3.10/site-packages/click/core.py", line 1055, in main
    rv = self.invoke(ctx)
  File "/Users/user/.virtualenvs/myproject/lib/python3.10/site-packages/click/core.py", line 1404, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/Users/user/.virtualenvs/myproject/lib/python3.10/site-packages/click/core.py", line 760, in invoke
    return __callback(*args, **kwargs)
  File "/Users/user/.virtualenvs/myproject/lib/python3.10/site-packages/db_to_sqlite/cli.py", line 166, in cli
    db.add_foreign_keys(foreign_keys_to_add_final)
  File "/Users/user/.virtualenvs/myproject/lib/python3.10/site-packages/sqlite_utils/db.py", line 1096, in add_foreign_keys
    cursor.execute(
sqlite3.OperationalError: table sqlite_master may not be modified

The only workaround I found online was this comment by awpears, but that means overwriting the db.py file

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

1 participant