conn.commit() records = romdb.decode_db(filedbfname, fields) for k, v in records.items(): if not db_fields.insert_fields(v): # constraint failure (no sys_name most likely) - skip the item continue for i in range(1, 7): abl = v["dropability" + str(i)] if abl != 0: cur.execute("INSERT INTO weapon_ability (guid, ordernum, abilityid) VALUES (%s,%s,%s)", (k, i, abl)) for i in range(1, 11): typeid = v["eqtype" + str(i)] typeval = v["eqtypevalue" + str(i)] if typeid != 0: cur.execute( "INSERT INTO weapon_weareq (guid, ordernum, typeid, value) VALUES (%s,%s,%s,%s)", (k, i, typeid, typeval), ) conn.commit() # finally, throw away weapon types where we have not a single item for cur.execute("DELETE FROM sys_weapontype w WHERE NOT EXISTS (SELECT NULL FROM weapon WHERE weapontype=w.id)") conn.commit() conn.close() # vim:set ts=2 sw=2: