Skip to content
encukou edited this page Feb 11, 2012 · 1 revision

The Pokédex library comes with a terminal command called pokedex, which allows interaction with and maintenance of the Pokédex database.

Syntax: pokedex {command} [options] [arguments...]

Global options

  • -e URI, --engine=URI — Specify the database to use, for either reading or writing. The database URI is passed directly to SQLAlchemy, and uses its engine syntax. If this is omitted, it will be read from the POKEDEX_DB_ENGINE environment variable; otherwise, the default is to use a SQLite database within the pokedex installation directory.
  • -i DIR, --index=DIR — Specify the location of the lookup index. This is just any old directory, used for storing a cached list of everything in the Pokédex. If this is omitted, it will be read from the POKEDEX_INDEX_DIR environment variable; otherwise, the default is to use a directory within the pokedex installation directory.
  • -q, --quiet — By default, plumbing commands (except setup) will announce the database, lookup index, and/or CSV directory they're using. dump and load also print progress information. Use this switch to hush them up.
  • -v, --verbose — Print the above information for user commands and setup, too.

Plumbing commands

setup

Populates a database, then builds a lookup index. This is the only plumbing command to be quiet by default, as it's intended to act as quick startup.

Note that if the pokedex library is installed in the system's Python library directory (usually via setup.py install), the default database and lookup index will also be placed in the system directory. If you needed root access to install pokedex, you will need root access to run setup using the defaults (this is a bad idea; refer to Getting Data for how to install properly).

status

Does nothing, but prints where pokedex thinks the database and lookup index are. Global options and environment variables are still respected.

load [tables...]

Creates tables and populates the database. The schema is in the pokedex.db.tables module, and the CSV data is, by default, in the module's data/csv directory.

To load only some specific tables, list them as extra arguments on the command line. Wildcards are supported. The tables are automatically loaded in dependency order.

Options:

  • -D, --drop-tables — Drop tables before loading them. Unless you're populating a fresh database, this is almost certainly what you want, but it's required out of mild paranoia.
  • -d DIR, --directory=DIR — Read CSV files from a different directory.
  • -r, --recursive — If you specify a list of tables to load, then also load their dependencies. For example, in a new database, you can't load only pokemon_types, because the tables it depends on don't exist. Likewise, in an existing database, you can't load only types, because it needs to be dropped first and other tables depend on it. With the -r option, pokedex will figure out the dependencies and reload them automatically.
  • -l LANGS, --langs=LANGS — Load translations for the given languages. By default, all available translations are loaded. Separate multiple languages by a comma (e.g. -l en,de,fr).

dump [tables...]

Inverse of load; dumps the database to CSV files. The schema is in the pokedex.db.tables module, and the CSV data is, by default, saved to the module's data/csv directory.

To dump only some specific tables, list them as extra arguments on the command line. Wildcards are supported.

Options:

  • -d DIR, --directory=DIR — Save CSV files to a different directory.
  • -l LANGS, --langs=LANGS — Dump unofficial texts for given languages. By default, English (en) is dumped. Separate multiple languages by a comma (e.g. -l en,de,fr). Use none to not dump any unofficial texts.

reindex

Rebuilds the lookup index from the database.

User commands

help

Prints a brief help message.

lookup {name}

Looks something up in the Pokédex. Requires both a populated database and a complete lookup index.