mirror of
https://github.com/veekun/pokedex.git
synced 2024-08-20 18:16:34 +00:00
Add the VersionGroupPokemonMoveMethod table
This commit is contained in:
parent
e15b1a257a
commit
48f3957aab
3 changed files with 112 additions and 0 deletions
35
scripts/version-group-pokemon-move-methods.py
Normal file
35
scripts/version-group-pokemon-move-methods.py
Normal file
|
@ -0,0 +1,35 @@
|
|||
# Encoding: UTF-8
|
||||
"""Fill the version_group_pokemon_move_methods table
|
||||
|
||||
This is an unmaintained one-shot script, only included in the repo for reference.
|
||||
|
||||
|
||||
"""
|
||||
|
||||
|
||||
from sqlalchemy.sql import exists, func
|
||||
from sqlalchemy.orm import lazyload
|
||||
from sqlalchemy import and_, or_, not_
|
||||
|
||||
from pokedex.db import connect, tables, load
|
||||
|
||||
session = connect()
|
||||
|
||||
session.query(tables.VersionGroupPokemonMoveMethod).delete()
|
||||
|
||||
q = session.query(tables.VersionGroup, tables.PokemonMoveMethod)
|
||||
q = q.filter(exists().where(and_(
|
||||
tables.PokemonMove.pokemon_move_method_id == tables.PokemonMoveMethod.id,
|
||||
tables.PokemonMove.version_group_id == tables.VersionGroup.id)))
|
||||
q = q.options(lazyload('*'))
|
||||
for version_group, pokemon_move_method in q:
|
||||
entry = tables.VersionGroupPokemonMoveMethod(
|
||||
version_group=version_group,
|
||||
pokemon_move_method=pokemon_move_method,
|
||||
)
|
||||
session.add(entry)
|
||||
|
||||
|
||||
load.dump(session, tables=['version_group_pokemon_move_methods'])
|
||||
print "Dumped to CSV, rolling back transaction"
|
||||
session.rollback()
|
Loading…
Add table
Add a link
Reference in a new issue