#!/usr/bin/env python3 import sqlite3 episodes = ['ep1', 'ep2', 'ep4'] difficulties = ['normal', 'hard', 'veryhard', 'ultimate'] sectionids = ['viridia', 'greenill', 'skyly', 'bluefull', 'purplenum', 'pinkal', 'redria', 'oran', 'yellowboze', 'whitill'] with open('drops','r') as infile: drops = infile.readlines() drops = [drop.strip() for drop in drops] ep1monsters = [ 'AlRappy', 'BarbarousWolf', 'Booma', 'Bulclaw', 'Canadine', 'Canane', 'ChaosBringer', 'ChaosSorcerer', 'Claw', 'DarkBelra', 'DarkGunner', 'Delsaber', 'Dimenian', 'Dubchic', 'EvilShark', 'Garanz', 'Gigobooma', 'Gillchic', 'Gobooma', 'GrassAssassin', 'GuilShark', 'Hidoom', 'Hildebear', 'Hildeblue', 'LaDimenian', 'Migium', 'Mothmant', 'NanoDragon', 'NarLily', 'PalShark', 'PanArms', 'PofuillySlime', 'PoisonLily', 'PouillySlime', 'RagRappy', 'SavageWolf', 'SinowBeat', 'SinowGold', 'SoDimenian', 'Dragon', 'DeRolLe', 'VolOpt', 'DarkFalz'] ep2monsters = [ 'BarbarousWolf', 'ChaosSorcerer', 'DarkBelra', 'Delbiter', 'Deldepth', 'DelLily', 'Delsaber', 'Dimenian', 'Dolmdarl', 'Dolmolm', 'Dubchic', 'EasterRappy', 'Epsilon', 'Garanz', 'Gee', 'Gibbles', 'GiGue', 'Gillchic', 'GrassAssassin', 'HalloRappy', 'Hidoom', 'Hildebear', 'Hildeblue', 'IllGill', 'LaDimenian', 'LoveRappy', 'Mericarol', 'Mericus', 'Merikle', 'Merillia', 'Meriltas', 'Migium', 'Morfos', 'Mothmant', 'NarLily', 'PanArms', 'PoisonLily', 'RagRappy', 'Recon', 'SavageWolf', 'SinowBerill', 'SinowSpigell', 'SinowZele', 'SinowZoa', 'SoDimenian', 'StRappy', 'UlGibbon', 'ZolGibbon', 'BarbaRay', 'GolDragon', 'GalGryphon', 'OlgaFlow'] ep4monsters = [ 'Astark', 'BaBoota', 'Boota', 'DelRappyCrater', 'DelRappyDesert', 'Dorphon', 'DorphonEclair', 'Girtablulu', 'Goran', 'GoranDetonator', 'MerissaA', 'MerissaAA', 'PazuzuCrater', 'PazuzuDesert', 'PyroGoran', 'SandRappyCrater', 'SandRappyDesert', 'SatelliteLizardCrater', 'SatelliteLizardDesert', 'YowieCrater', 'YowieDesert', 'ZeBoota', 'ZuCrater', 'ZuDesert', 'SaintMillion', 'Shambertin', 'Kondrieu'] epmonsters = { 'ep1': ep1monsters, 'ep2': ep2monsters, 'ep4': ep4monsters } conn = sqlite3.connect('elsewaredrops.db') #conn = sqlite3.connect('memory:') curs = conn.cursor() def create_table(): curs.execute('CREATE TABLE IF NOT EXISTS drops (episode TEXT, difficulty TEXT, sectionid TEXT, monster TEXT, item TEXT, rate REAL)') #conn.commit() curs.execute("SELECT COUNT(*) FROM drops") result = curs.fetchall() if result[0][0] == 0: for drop in drops: line = drop.strip().split(',') curs.execute("INSERT INTO drops (episode, difficulty, sectionid, monster, item, rate) VALUES (?, ?, ?, ?, ?, ?)", (line[0], line[1], line[2], line[3], line[4], line[5])) else: print("already data in the db") conn.commit() print('elseware drops') for episode in episodes: for difficulty in difficulties: print('{} {}'.format(episode, difficulty)) print('enemy', sep='', end='') for sectionid in sectionids: print(',{}'.format(sectionid), sep='', end='') print() for monster in epmonsters[episode]: print('{}'.format(monster), sep='', end='') curs.execute("SELECT item FROM drops WHERE episode = '{}' AND difficulty = '{}' AND monster = '{}'".format(episode, difficulty, monster)) rows = curs.fetchall() for row in rows: print(',{}'.format(row[0]), sep='', end='') print() print() print() curs.close() conn.close()