new web index, refactor, data fixes

This commit is contained in:
Bryce Allen
2015-05-20 11:05:32 -05:00
parent 9bad89b0af
commit f6fa342ac4
12 changed files with 341 additions and 151 deletions

Binary file not shown.

44
db/set_weapon_costs.py Executable file
View File

@@ -0,0 +1,44 @@
#!/usr/bin/env python
import os.path
import codecs
import csv
import _pathfix
from mhapi.db import MHDB
def set_upgrade_cost(db, item_id, upgrade_cost):
print "upgrade_cost", item_id, upgrade_cost
cur = db.cursor()
cur.execute("""UPDATE weapons SET
upgrade_cost=? WHERE _id=?""",
(upgrade_cost, item_id))
def set_creation_cost(db, item_id, creation_cost):
print "creation_cost", item_id, creation_cost
cur = db.cursor()
cur.execute("""UPDATE weapons SET
creation_cost=? WHERE _id=?""",
(creation_cost, item_id))
if __name__ == '__main__':
db = MHDB()
delta_file_path = os.path.join(_pathfix.db_path, "weapons-delta.csv")
with open(delta_file_path) as f:
reader = csv.DictReader(f)
for row in reader:
item_id = row["id"]
creation_cost = row["creation_cost"]
upgrade_cost = row["upgrade_cost"]
if creation_cost:
set_creation_cost(db, item_id, creation_cost)
if upgrade_cost:
set_upgrade_cost(db, item_id, upgrade_cost)
db.commit()
db.close()

3
db/weapons-delta.csv Normal file
View File

@@ -0,0 +1,3 @@
id,name,creation_cost,upgrade_cost
6302,"Defender's Lance",3225,2150
6808,"Demonlord Cudgel",,100000
1 id name creation_cost upgrade_cost
2 6302 Defender's Lance 3225 2150
3 6808 Demonlord Cudgel 100000