pokeapi icon indicating copy to clipboard operation
pokeapi copied to clipboard

Error when setting up database locally: `No such table: pokemon_v2_language`

Open jgarrow opened this issue 4 years ago • 4 comments

When running the build script to generate the sqlite3 database locally on my machine, I get an error that says No such table: pokemon_v2_language. The db.sqlite3 file that gets created has no tables in it.

Steps to Reproduce:

  1. Clone repo to computer by running git clone https://github.com/PokeAPI/pokeapi.git --recurse-submodules
  2. Open repo
  3. Navigate to MAKEFILE and change all pip commands to pip3 and python to python3 (otherwise my machine will use the wrong versions).
  4. In the root of the repo, run make install
  5. Run python3 manage.py shell --settings-config.local
  6. Run the build script
from data.v2.build import build_all
build_all()
  1. See error message
Traceback (most recent call last):
  File "/usr/local/lib/python3.9/site-packages/django/db/backends/utils.py", line 85, in _execute
    return self.cursor.execute(sql, params)
  File "/usr/local/lib/python3.9/site-packages/django/db/backends/sqlite3/base.py", line 298, in execute
    return Database.Cursor.execute(self, query, params)
sqlite3.OperationalError: no such table: pokemon_v2_language
  1. Open db.sqlite3 file in the root of the repo that was generated by the build script and note the lack of tables

Additional notes

I used this same approach about a year ago and had no problems generating the sqlite3 file. I don't need to run the server or anything, hence the skipped make setup and make serve steps. I just need to generate the sqlite3 file. I'm not sure if there have been changes made that are not reflected in the README instructions, so any clarification is much appreciated!

jgarrow avatar Oct 01 '21 03:10 jgarrow

I cloned a fresh repo and did your steps and got that same error. But I think the make setup command has to be run to apply the migrations to the database. Once I ran that command, I ran the shell commands and it built it properly for me. Perhaps that's the issue?

C-Garza avatar Oct 01 '21 11:10 C-Garza

Yeah, make migrate is needed to obtain the latest schema. It should take long.

Anyways, I strongly advise you to use the docker-compose installation, that, under the hood, uses a Postgres DB.

Naramsim avatar Oct 01 '21 14:10 Naramsim

Ahh thanks @C-Garza, that worked like a charm! Would y'all mind if I opened a PR to add a clarification note on the README that the make setup command needs to be run to apply the migrations (in addition to setting up the local dev environment)?

jgarrow avatar Oct 01 '21 16:10 jgarrow

Yes of course ;)

Naramsim avatar Oct 03 '21 19:10 Naramsim