pokeapi
pokeapi copied to clipboard
Error when setting up database locally: `No such table: pokemon_v2_language`
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:
- Clone repo to computer by running
git clone https://github.com/PokeAPI/pokeapi.git --recurse-submodules - Open repo
- Navigate to
MAKEFILEand change allpipcommands topip3andpythontopython3(otherwise my machine will use the wrong versions). - In the root of the repo, run
make install - Run
python3 manage.py shell --settings-config.local - Run the build script
from data.v2.build import build_all
build_all()
- 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
- Open
db.sqlite3file 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!
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?
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.
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)?
Yes of course ;)