Dex Docs
Updating the Database
Updating the Database
This server uses a SQLite3 database created from the PokéAPI GitHub repo. If you would like to grab the most up-to-date database or clone your own to host your own server, you'll need to have Python3 installed. If you don't have it already, you can find the download on the Python website.
Here are some steps if following the instructions on the PokéAPI GitHub repo are unclear or aren't working:
- Clone the PokéAPI repo to your computer and open it up in your code editor
git clone https://github.com/PokeAPI/pokeapi.git
- **Skip this step if your
pip
andpython
commands are already running onpip3
andpython3
respectively. If not, you might have to update the scripts -- navigate toMakefile
at the root of the project. Here, we're going to update all of the script commands to usepip3
instead ofpip
so that we can use Python3. The updated file should look like this:
1.PHONY: help23help:4 @grep -E '^[a-zA-Z_-]+:.*?# .*$$' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?# "}; {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}'567install: # Install base requirements to run project8 pip3 install -r requirements.txt910dev-install: # Install developer requirements + base requirements11 pip3 install -r test-requirements.txt1213setup: # Set up the project database14 python3 manage.py migrate --settings=config.local1516wipe_db: # Delete's the project database17 rm -rf db.sqlite31819serve: # Run the project locally20 python3 manage.py runserver --settings=config.local2122test: # Run tests23 python3 manage.py test --settings=config.local2425clean: # Remove any pyc files26 find . -type f -name '*.pyc' -delete2728migrate: # run any outstanding migrations29 python3 manage.py migrate --settings=config.local3031shell: # Load a shell32 python3 manage.py shell --settings=config.local3334format: # Format the source code35 black .3637format-check: # Check the source code has been formatted38 black . --check
- Now we can install the requirements
# this will install all of the required packages and libraries for using PokéAPImake install
- Start up the Django shell
# Update the `python` script to use `python3` if necessarypython manage.py shell --settings=config.local
- Run the build script
from data.v2.build import build_allbuild_all()
- The database will be found in the root of the project as
db.sqlite3
. You can now move this database file to your GraphQL Pokédex Server repo! Just replace thedb.sqlite3
file in the server repo (src/data
) with your new one.