Have you ever wanted to to play pokemon, but also cheat? Is the GameGenie interface a little bit too user friendly for you? Do you want to do inner joins on lists of Pokemon?
PostgresPlaysPokemon is for you!
The "server" in this case is a visual emulator that exposes a GRPC interface. It is written in Python, and requires pypy to run at a reasonable speed. You'll need the Python2 PyPy version pending resolution of this issue.
- Install pypy and SDL.
- Set up a virtualenv:
virtualenv -p $(which pypy) venv
- Activate the virtualenv:
- Install the requirements:
pip install -r requirements.txt
maketo build the protobufs
- Launch the emulator:
You'll also need a Pokemon Red ROM. Place it in [
The "client" is a postgres extension. You first need to compile it, then make Postgres aware of it, and then you can use it!
- Install rust and cargo
- Install Postgres. I test with Postgres 10; Other versions may or may not work.
maketo build the extension
sudo make installto install all the required files where Postgres expects them.
- If you don't have one already, set up a postgres admin.
On Linux at least, if you make a superuser matching your username and a database matching your username, you can just type
- Get a
psqlshell. It doesn't matter what database you use, where we're going we don't need databases!
CREATE EXTENSION pokemon;
IMPORT FOREIGN SCHEMA red FROM SERVER red INTO public;
- All done!
|Table||Cooresponds To||Operations Supported|
|party||Your (up to) six pokemon||SELECT, UPDATE|
|inventory||Items you're carryin||SELECT, INSERT, UPDATE|
|story||Critical story event triggers||SELECT, UPDATE|
There's also a CLI that performs much of the same actions as the Postgres API.
cargo run -- --help should list all available operations.
You'll need rust and cargo but not Postgres.
But where's the fun in that?
How it Works
In the same process that's running the emulator, a GRPC server is listening for commands. Using PyBoy's API, the server looks manipulates the emulated Gameboy's memory.
Right now, that server is exposed over a unix socket which the database server can connect to.
The client uses Rust to translate SQL commands into GRPC, which connects