source_entries
James Miller 2019-11-12 20:37:40 -06:00
parent 8b90c5ff01
commit 14f9291836
1 changed files with 5 additions and 0 deletions

View File

@ -46,6 +46,7 @@ def main():
data = yaml.full_load(yl) data = yaml.full_load(yl)
do_damage(data, conn) do_damage(data, conn)
def do_damage(data, conn): def do_damage(data, conn):
# make the four tables # make the four tables
do_damage_sub_tables(data, conn) do_damage_sub_tables(data, conn)
@ -106,6 +107,7 @@ INSERT INTO damagetype(name, abbr, damagecategory_id)
# now link the source entries to the damage types # now link the source entries to the damage types
link_sourceentry_damagetype(i['name'], srcentrydata, conn) link_sourceentry_damagetype(i['name'], srcentrydata, conn)
def link_sourceentry_damagecategory(name, srcentrydata, conn): def link_sourceentry_damagecategory(name, srcentrydata, conn):
stmt = """ stmt = """
INSERT INTO sourceentry_damagecategory (sourceentry_id, damagecategory_id) INSERT INTO sourceentry_damagecategory (sourceentry_id, damagecategory_id)
@ -129,6 +131,7 @@ INSERT INTO sourceentry_damagecategory (sourceentry_id, damagecategory_id)
conn.commit() conn.commit()
pass pass
def link_sourceentry_damagetype(name, srcentrydata, conn): def link_sourceentry_damagetype(name, srcentrydata, conn):
stmt = """ stmt = """
INSERT INTO sourceentry_damagetype (sourceentry_id, damagetype_id) INSERT INTO sourceentry_damagetype (sourceentry_id, damagetype_id)
@ -152,6 +155,7 @@ INSERT INTO sourceentry_damagetype (sourceentry_id, damagetype_id)
conn.commit() conn.commit()
pass pass
def util_insert_into_sourceentry(data, conn): def util_insert_into_sourceentry(data, conn):
# print("srcentrydata: {}".format(data)) # print("srcentrydata: {}".format(data))
stmt = "INSERT INTO sourceentry (source_id, page_start, page_stop) VALUES ((SELECT source_id FROM source WHERE abbr=?),?,?)" stmt = "INSERT INTO sourceentry (source_id, page_start, page_stop) VALUES ((SELECT source_id FROM source WHERE abbr=?),?,?)"
@ -172,6 +176,7 @@ def util_insert_into_sourceentry(data, conn):
else: else:
conn.commit() conn.commit()
def do_damage_sub_tables(data, conn): def do_damage_sub_tables(data, conn):
table = """ table = """
CREATE TABLE damagecategory ( CREATE TABLE damagecategory (