got spells.py fixing the nethys sources_pages field

merge-requests/29/head
James Miller 2019-08-08 21:01:12 -05:00
parent d9ffb127e4
commit 5f50cd2231
2 changed files with 37 additions and 11 deletions

View File

@ -36,8 +36,34 @@ def main():
# insert basics of a spell # insert basics of a spell
do_basic_sql(i, id, conn) do_basic_sql(i, id, conn)
do_range_numbers(i,id,conn) do_range_numbers(i,id,conn)
do_sources_pages(i,id,conn)
# TODO do all the traits, FK stuff etc... # TODO do all the traits, FK stuff etc...
def do_sources_pages(i, id, conn):
if 'source' not in i:
return
print(i)
res = ''
source_id = 0
# Do Core Rulebook branch
if "Core Rulebook" in i['source']:
res = i['source'].replace('Core Rulebook pg.','').strip()
source_id = 1
stmt = "UPDATE spells SET sources_id=?, sources_pages=? WHERE spells_id=?"
inp = (source_id, res, id)
try:
conn.execute(stmt, inp)
except:
print("Error updating sources")
else:
conn.commit()
def do_range_numbers(i, id, conn): def do_range_numbers(i, id, conn):
# no need to do range # no need to do range
if 'range' not in i: if 'range' not in i:

View File

@ -28,17 +28,17 @@ CREATE TABLE spellschools (
-- UNIQUE as sanity requires :) -- UNIQUE as sanity requires :)
CREATE TABLE spells ( CREATE TABLE spells (
spells_id INTEGER PRIMARY KEY, spells_id INTEGER PRIMARY KEY,
sources_id INTEGER NOT NULL, sources_id INTEGER NOT NULL, -- manually entered right now
sources_pages TEXT, sources_pages TEXT, -- TODO convert to our format in spells.py
name TEXT NOT NULL UNIQUE, name TEXT NOT NULL UNIQUE, -- scraped from github repo
level INTEGER, level INTEGER, -- scraped from github repo
trigger TEXT, trigger TEXT, -- TODO in spells.py
descr TEXT, descr TEXT, -- scraped from github repo
spelltypes_id INTEGER, spelltypes_id INTEGER, -- TODO in spells.py
range_text TEXT, range_text TEXT, -- scraped from github repo
range_ft INTEGER, range_ft INTEGER, -- generated from text in spells.py
targets TEXT, targets TEXT, -- TODO in spells.py
nethysurl TEXT, nethysurl TEXT, -- scraped from github repo
FOREIGN KEY (sources_id) REFERENCES sources(sources_id), FOREIGN KEY (sources_id) REFERENCES sources(sources_id),
FOREIGN KEY (spelltypes_id) REFERENCES spelltypes(spelltypes_id) FOREIGN KEY (spelltypes_id) REFERENCES spelltypes(spelltypes_id)
); );