pokemaster2.db package

Submodules

pokemaster2.db.default module

Database connection helpers.

pokemaster2.db.default.csv_dir() str[source]

Get only the default csv path, omitting the origin.

pokemaster2.db.default.csv_dir_with_origin() Tuple[str, str][source]

Determine the default csv path.

Returns

Tuple[CSV file path, the origin of the CSV path]

pokemaster2.db.default.db_uri() str[source]

Get only the default db uri, omitting the origin.

pokemaster2.db.default.db_uri_with_origin() Tuple[str, str][source]

Determine the default db uri.

Returns

Tuple[DB URI, the origin of the URI]

pokemaster2.db.io module

Load csv files into database.

pokemaster2.db.io.get_csv_dir(csv_dir: Optional[str] = None) str[source]

Return the csv dir we are about to use.

pokemaster2.db.io.get_database(uri: Optional[str] = None) peewee.SqliteDatabase[source]

Connect to and return a database.

pokemaster2.db.io.load(database: peewee.SqliteDatabase, csv_dir: str, models: Optional[Sequence[pokemaster2.db.tables.BaseModel]] = None, drop_tables: bool = False, safe: bool = True, recursive: bool = True) None[source]

Load data from CSV files into the given database.

Parameters
  • databasepeewee database to use.

  • models – List of tables to load. If omitted, all tables are loaded.

  • csv_dir – Directory the CSV files reside in.

  • drop_tables – Existing tables will be dropped if True.

  • safe – Load can be faster if set to False, but can corrupt the db if it crashes / interrupted.

  • recursive – Load all dependent tables if set to True.

Returns

Nothing.

pokemaster2.db.tables module

The pokedex database models.

class pokemaster2.db.tables.BaseModel(*args, **kwargs)[source]

Bases: peewee.Model

BaseModel for all pokdex Models.

DoesNotExist

alias of pokemaster2.db.tables.BaseModelDoesNotExist

id = <AutoField: BaseModel.id>
class pokemaster2.db.tables.Pokemon(*args, **kwargs)[source]

Bases: pokemaster2.db.tables.BaseModel

A Pokémon. The core to this whole mess.

This table defines “Pokémon” the same way the games do: a form with different types, moves, or other game-changing properties counts as a different Pokémon. For example, this table contains four rows for Deoxys, but only one for Unown.

Non-default forms have IDs above 10000. IDs below 10000 match the species_id column, for convenience.

DoesNotExist

alias of pokemaster2.db.tables.PokemonDoesNotExist

base_experience = <IntegerField: Pokemon.base_experience>
height = <IntegerField: Pokemon.height>
id = <IntegerField: Pokemon.id>
identifier = <CharField: Pokemon.identifier>
is_default = <BooleanField: Pokemon.is_default>
order = <IntegerField: Pokemon.order>
species = <ForeignKeyField: (unbound)>
species_id = <IntegerField: Pokemon.species_id>
weight = <IntegerField: Pokemon.weight>
class pokemaster2.db.tables.PokemonSpecies(*args, **kwargs)[source]

Bases: pokemaster2.db.tables.BaseModel

A Pokémon species: the standard 1–151. Or 649. Whatever.

ID matches the National Pokédex number of the species.

DoesNotExist

alias of pokemaster2.db.tables.PokemonSpeciesDoesNotExist

base_happiness = <IntegerField: PokemonSpecies.base_happiness>
capture_rate = <IntegerField: PokemonSpecies.capture_rate>
conquest_order = <IntegerField: PokemonSpecies.conquest_order>
evolves_from_species_id = <ForeignKeyField: PokemonSpecies.evolves_from_species_id>
evolves_from_species_id_id = <ForeignKeyField: PokemonSpecies.evolves_from_species_id>
evolves_to
forms_switchable = <BooleanField: PokemonSpecies.forms_switchable>
gender_rate = <IntegerField: PokemonSpecies.gender_rate>
has_gender_differences = <BooleanField: PokemonSpecies.has_gender_differences>
hatch_counter = <IntegerField: PokemonSpecies.hatch_counter>
id = <IntegerField: PokemonSpecies.id>
identifier = <CharField: PokemonSpecies.identifier>
is_baby = <BooleanField: PokemonSpecies.is_baby>
order = <IntegerField: PokemonSpecies.order>
pokemaster2.db.tables.get_pokemon(identifier: str) List[pokemaster2.db.tables.Pokemon][source]

Find a single Pokemon instance.

Module contents

Database stuff.