spelltargets table populating, but not linked to FK on spells yet
parent
cfdef83cb2
commit
b2df5a9ae3
|
@ -68,6 +68,34 @@ def main():
|
|||
### print(len(trigs))
|
||||
### print(len(set(trigs)))
|
||||
|
||||
# List the various targets and see if there are any duplicates
|
||||
## YES, there are MANY duplicates, so we need a separate targets table
|
||||
targs = []
|
||||
for i in sorted_dicts:
|
||||
if 'targets' in i:
|
||||
targs.append(i['targets'])
|
||||
dedup_targs = set(targs)
|
||||
sorted_targs = sorted(dedup_targs)
|
||||
inp_targs = []
|
||||
id = 0
|
||||
for i in sorted_targs:
|
||||
id += 1
|
||||
inp_targs.append((id,i))
|
||||
stmt = "INSERT INTO spelltargets (spelltargets_id, name) VALUES (?,?)"
|
||||
try:
|
||||
conn.executemany(stmt,inp_targs)
|
||||
except:
|
||||
print("Error creating targets")
|
||||
else:
|
||||
conn.commit()
|
||||
|
||||
|
||||
|
||||
|
||||
# print(sorted(targs))
|
||||
# print(len(targs))
|
||||
# print(len(set(targs)))
|
||||
|
||||
|
||||
id = 0
|
||||
for i in sorted_dicts:
|
||||
|
|
|
@ -15,6 +15,11 @@ CREATE TABLE spelltraditions (
|
|||
name TEXT NOT NULL UNIQUE
|
||||
);
|
||||
|
||||
CREATE TABLE spelltargets (
|
||||
spelltargets_id INTEGER PRIMARY KEY,
|
||||
name TEXT NOT NULL UNIQUE
|
||||
);
|
||||
|
||||
CREATE TABLE spellschools (
|
||||
spellschools_id INTEGER PRIMARY KEY,
|
||||
sources_id INTEGER NOT NULL,
|
||||
|
@ -41,10 +46,11 @@ CREATE TABLE spells (
|
|||
range_text TEXT, -- scraped from github repo
|
||||
range_ft INTEGER, -- generated from text in spells.py
|
||||
area_text TEXT, -- TODO need to figure out some sort of programmatic representation for this too
|
||||
targets TEXT, -- TODO in spells.py
|
||||
spelltargets_id INTEGER,
|
||||
nethysurl TEXT, -- scraped from github repo
|
||||
FOREIGN KEY (sources_id) REFERENCES sources(sources_id),
|
||||
FOREIGN KEY (spelltypes_id) REFERENCES spelltypes(spelltypes_id)
|
||||
FOREIGN KEY (spelltypes_id) REFERENCES spelltypes(spelltypes_id),
|
||||
FOREIGN KEY (spelltargets_id) REFERENCES spelltargets(spelltargets_id)
|
||||
);
|
||||
|
||||
CREATE TABLE spells_spellcomponents(
|
||||
|
|
Loading…
Reference in New Issue