Load the Pokemon data
Let's load the Pokemon data from the open-source db. We'll need a small standalone Python project for that.
Create a folder called pokemon-python
and a file named load_pokemon.py
:
import pandas as pd
from sqlalchemy import create_engine
engine = create_engine('postgresql://postgres:password@xxxxx.xxxxx.us-east-2.rds.amazonaws.com:5432/postgres')
df=pd.read_csv('https://raw.githubusercontent.com/veekun/pokedex/master/pokedex/data/csv/pokemon.csv')
df.to_sql('pokemon', engine)
cd pokemon-python
# create a venv
pip install virtualenv
python3 -m venv env
# To activate
source env/bin/activate
For an easier and robust deployment of Postgres instances, checkout Rocketgraph
pip3 install pandas
pip3 install sqlalchemy
And for good measure
pip3 freeze > requirements.txt
Now simply run
python3 load_pokemon.py
if you get an error such as
ModuleNotFoundError: No module named 'psycopg2'
simply install it:
pip install psycopg2-binary
Once you run that command, psql
into your PostgresDB to ensure that Pokemon data is loaded:
psql postgresql://postgres:password@restless-pine.xxxxxxxxxxx.us-east-2.rds.amazonaws.com:5432/postgres
And:
SELECT * FROM pokemon LIMIT 10;
You should see a few Pokemon there. Congrats, you loaded the Pokemon data and setup a front-end succesfully.
Top comments (0)