Forem

Cover image for Load Pokemon data into Postgres
Kaushik Varanasi
Kaushik Varanasi

Posted on • Edited on

5

Load Pokemon data into Postgres

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)
Enter fullscreen mode Exit fullscreen mode
cd pokemon-python
Enter fullscreen mode Exit fullscreen mode
# create a venv
pip install virtualenv
python3 -m venv env
Enter fullscreen mode Exit fullscreen mode
# To activate
source env/bin/activate
Enter fullscreen mode Exit fullscreen mode

For an easier and robust deployment of Postgres instances, checkout Rocketgraph

pip3 install pandas
pip3 install sqlalchemy
Enter fullscreen mode Exit fullscreen mode

And for good measure

pip3 freeze > requirements.txt
Enter fullscreen mode Exit fullscreen mode

Now simply run

python3 load_pokemon.py
Enter fullscreen mode Exit fullscreen mode

if you get an error such as

ModuleNotFoundError: No module named 'psycopg2'

simply install it:

pip install psycopg2-binary
Enter fullscreen mode Exit fullscreen mode

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
Enter fullscreen mode Exit fullscreen mode

And:

SELECT * FROM pokemon LIMIT 10;
Enter fullscreen mode Exit fullscreen mode

You should see a few Pokemon there. Congrats, you loaded the Pokemon data and setup a front-end succesfully.

Image of Timescale

🚀 pgai Vectorizer: SQLAlchemy and LiteLLM Make Vector Search Simple

We built pgai Vectorizer to simplify embedding management for AI applications—without needing a separate database or complex infrastructure. Since launch, developers have created over 3,000 vectorizers on Timescale Cloud, with many more self-hosted.

Read full post →

Top comments (0)

Image of Docusign

🛠️ Bring your solution into Docusign. Reach over 1.6M customers.

Docusign is now extensible. Overcome challenges with disconnected products and inaccessible data by bringing your solutions into Docusign and publishing to 1.6M customers in the App Center.

Learn more