Skip to content

[development] Error when running loaddata: no such table: projects_project__old #5385

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

Closed
BenMusch opened this issue Mar 2, 2019 · 7 comments

Comments

@BenMusch
Copy link

BenMusch commented Mar 2, 2019

Running into some issues when setting up the application locally. I'm running:

  • macOS 10.14 (18A391)
  • python 3.7.2
  • sqlite3 2.6.0

After installing dependencies and migrating the database, I get this error when running python manage.py loaddata:

Traceback (most recent call last):
  File "/Users/ben/.virtualenvs/docs/lib/python3.7/site-packages/django/db/backends/utils.py", line 62, in execute
    return self.cursor.execute(sql)
  File "/Users/ben/.virtualenvs/docs/lib/python3.7/site-packages/django/db/backends/sqlite3/base.py", line 326, in execute
    return Database.Cursor.execute(self, query)
sqlite3.OperationalError: no such table: projects_project__old

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "manage.py", line 11, in <module>
    execute_from_command_line(sys.argv)
  File "/Users/ben/.virtualenvs/docs/lib/python3.7/site-packages/django/core/management/__init__.py", line 364, in execute_from_command_line
    utility.execute()
  File "/Users/ben/.virtualenvs/docs/lib/python3.7/site-packages/django/core/management/__init__.py", line 356, in execute
    self.fetch_command(subcommand).run_from_argv(self.argv)
  File "/Users/ben/.virtualenvs/docs/lib/python3.7/site-packages/django/core/management/base.py", line 283, in run_from_argv
    self.execute(*args, **cmd_options)
  File "/Users/ben/.virtualenvs/docs/lib/python3.7/site-packages/django/core/management/base.py", line 330, in execute
    output = self.handle(*args, **options)
  File "/Users/ben/.virtualenvs/docs/lib/python3.7/site-packages/django/core/management/commands/loaddata.py", line 69, in handle
    self.loaddata(fixture_labels)
  File "/Users/ben/.virtualenvs/docs/lib/python3.7/site-packages/django/core/management/commands/loaddata.py", line 115, in loaddata
    connection.check_constraints(table_names=table_names)
  File "/Users/ben/.virtualenvs/docs/lib/python3.7/site-packages/django/db/backends/sqlite3/base.py", line 286, in check_constraints
    column_name, referenced_column_name,
  File "/Users/ben/.virtualenvs/docs/lib/python3.7/site-packages/django/db/backends/utils.py", line 79, in execute
    return super(CursorDebugWrapper, self).execute(sql, params)
  File "/Users/ben/.virtualenvs/docs/lib/python3.7/site-packages/django/db/backends/utils.py", line 64, in execute
    return self.cursor.execute(sql, params)
  File "/Users/ben/.virtualenvs/docs/lib/python3.7/site-packages/django/db/utils.py", line 94, in __exit__
    six.reraise(dj_exc_type, dj_exc_value, traceback)
  File "/Users/ben/.virtualenvs/docs/lib/python3.7/site-packages/django/utils/six.py", line 685, in reraise
    raise value.with_traceback(tb)
  File "/Users/ben/.virtualenvs/docs/lib/python3.7/site-packages/django/db/backends/utils.py", line 62, in execute
    return self.cursor.execute(sql)
  File "/Users/ben/.virtualenvs/docs/lib/python3.7/site-packages/django/db/backends/sqlite3/base.py", line 326, in execute
    return Database.Cursor.execute(self, query)
django.db.utils.OperationalError: Problem installing fixtures: no such table: projects_project__old

I've done some digging, and it seems potentially related to this issue with django. However, people commenting on that issue have said that their code worked with Django 1.11, so it's not clear why it would be breaking with this version

The root cause supposedly has to do with a change when going from sqlite 2.5.0 -> 2.6.0, but changing the sqlite version that python uses seems to be quite complicated and I haven't been able to downgrade it.

So far, I've tried manually editing the sqlite3/schema.rb file with django in my virtualenv to include the code in the PR which fixed Django, but that didn't fix my code

Right now, I'm in the middle of upgrading django locally to see if I can get the loaddata command to work then. Still fails even if I upgrade my local django version. Is there anything else I should try?

Let me know if I can provide any more information

@BenMusch BenMusch changed the title [evelopment] Error when running loaddata: [development] Error when running loaddata: no such table: projects_project__old Mar 2, 2019
@stsewd
Copy link
Member

stsewd commented Mar 2, 2019

Like you mention, this is a bug in django not from read the docs. You need to downgrade your sqlite version. I'm using this in fedora 29 dnf install sqlite-3.24.0-2.fc29.x86_64

@stsewd stsewd closed this as completed Mar 2, 2019
@BenMusch
Copy link
Author

BenMusch commented Mar 2, 2019

@stsewd Do you know off-hand of any workaround people are using on Mac OS? My system sqlite version is 3.22, but python ships with 3.26 and I can't find any method to change that version on Mac

@davidfischer
Copy link
Contributor

I'm using both Python and sqlite from homebrew and I was able to just switch to the older version of sqlite.

brew switch sqlite3 3.25.2    # see the versions you have with brew info sqlite3
# Possibly needed if you are using the latest readline as well
brew switch readline 7.0.5    # brew info readline

After running that, I saw the following:

echo $(python -c "import sqlite3; print(sqlite3.version); print(sqlite3.sqlite_version)")
2.6.0 3.25.2

@BenMusch
Copy link
Author

@davidfischer thanks I'll try that out -- haven't tried switching readline yet

@ghost
Copy link

ghost commented Aug 21, 2019

Hey, I am not able to figure it out yet. I use ubuntu. My SQLite version is 3.27.2. Beginner to SQL, how do I fix this issue?

@stsewd
Copy link
Member

stsewd commented Aug 21, 2019

@geekRishabhjain you need sqlite < 3.26, check https://docs.readthedocs.io/en/stable/development/install.html#requirements

@ghost
Copy link

ghost commented Aug 21, 2019

I can't find any method for ubuntu. Can anyone please tell me any terminal command to install an older version of sqlite? And how to set my django project to use it instead of the former

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