still working on spell import
parent
40a1c23c8c
commit
85f251adc3
|
@ -29,12 +29,41 @@ def main():
|
||||||
|
|
||||||
## Get database connection
|
## Get database connection
|
||||||
conn = sqlite3.connect('../../pf2.db')
|
conn = sqlite3.connect('../../pf2.db')
|
||||||
|
|
||||||
|
id = 0
|
||||||
for i in sorted_dicts:
|
for i in sorted_dicts:
|
||||||
do_sql(i)
|
id += 1
|
||||||
|
do_sql(i, id, conn)
|
||||||
|
|
||||||
# TODO write this function after sql schema drafted
|
# TODO write this function after sql schema drafted
|
||||||
def do_sql():
|
def do_sql(i, id, conn):
|
||||||
pass
|
print("Doing spell id #{}: {}".format(id, i['name']))
|
||||||
|
stmt = """INSERT INTO spells (
|
||||||
|
spells_id,
|
||||||
|
sources_id,
|
||||||
|
sources_pages,
|
||||||
|
nethysurl,
|
||||||
|
name,
|
||||||
|
source,
|
||||||
|
level,
|
||||||
|
descr,
|
||||||
|
range_text)
|
||||||
|
VALUES (?,?,?,?,?,?,?,?,?)"""
|
||||||
|
|
||||||
|
rge = None
|
||||||
|
if 'range' in i:
|
||||||
|
rge = i['range']
|
||||||
|
|
||||||
|
dscr = None
|
||||||
|
if 'description' in i:
|
||||||
|
dscr = i['description']
|
||||||
|
|
||||||
|
inp = (id, 1, None, i['nethysUrl'], i['name'], i['source'], i['level'], dscr, rge)
|
||||||
|
try:
|
||||||
|
conn.execute(stmt, inp)
|
||||||
|
except:
|
||||||
|
print("Error")
|
||||||
|
conn.commit()
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
|
|
|
@ -35,7 +35,7 @@ CREATE TABLE spells (
|
||||||
level INTEGER NOT NULL,
|
level INTEGER NOT NULL,
|
||||||
trigger TEXT,
|
trigger TEXT,
|
||||||
descr TEXT NOT NULL,
|
descr TEXT NOT NULL,
|
||||||
spelltypes_id INTEGER NOT NULL,
|
spelltypes_id INTEGER,
|
||||||
range_text TEXT,
|
range_text TEXT,
|
||||||
range_ft INTEGER,
|
range_ft INTEGER,
|
||||||
targets TEXT,
|
targets TEXT,
|
||||||
|
|
Loading…
Reference in New Issue