got ability scores populating
parent
3aff6367c2
commit
998f331bcc
|
@ -1,4 +1,62 @@
|
|||
import yaml
|
||||
import sqlite3
|
||||
import os
|
||||
|
||||
DBFILE = 'tmp.db'
|
||||
|
||||
def main():
|
||||
# delete DBfile and run fresh
|
||||
os.remove(DBFILE)
|
||||
|
||||
# Load in the yaml data
|
||||
with open('basics.yaml') as yl:
|
||||
data = yaml.full_load(yl)
|
||||
|
||||
## Get database connection
|
||||
conn = sqlite3.connect(DBFILE) # eventually hook this up to be the main db
|
||||
## Set pragmas
|
||||
pragma1 = "PRAGMA synchronous=OFF;"
|
||||
pragma2 = "PRAGMA count_changes=OFF;"
|
||||
pragma3 = "PRAGMA journal_mode=MEMORY;"
|
||||
pragma4 = "PRAGMA temp_store=MEMORY;"
|
||||
pragma5 = "PRAGMA foreign_keys=ON;"
|
||||
conn.execute(pragma1)
|
||||
conn.execute(pragma2)
|
||||
conn.execute(pragma3)
|
||||
conn.execute(pragma4)
|
||||
conn.execute(pragma5)
|
||||
|
||||
# call the functions to input to SQL
|
||||
do_abilityscore(data['abilityscore'], conn)
|
||||
|
||||
def do_abilityscore(data, conn):
|
||||
print(data)
|
||||
print(conn)
|
||||
|
||||
table = """
|
||||
CREATE TABLE abilityscore (
|
||||
abilityscore_id INTEGER PRIMARY KEY,
|
||||
flag_rep INTEGER NOT NULL,
|
||||
short_name TEXT NOT NULL UNIQUE,
|
||||
long_name TEXT NOT NULL UNIQUE
|
||||
);
|
||||
"""
|
||||
|
||||
c = conn.cursor()
|
||||
c.execute(table)
|
||||
|
||||
inp_data = []
|
||||
for i in data:
|
||||
inp_data.append((i['flag_rep'], i['short_name'], i['long_name']))
|
||||
|
||||
stmt = "INSERT INTO abilityscore (flag_rep, short_name, long_name) VALUES (?,?,?)"
|
||||
try:
|
||||
conn.executemany(stmt,inp_data)
|
||||
except:
|
||||
print("Error creating abilityscore")
|
||||
else:
|
||||
conn.commit()
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
main()
|
||||
|
|
|
@ -24,7 +24,6 @@ abilityscore:
|
|||
- flag_rep: 128
|
||||
short_name: Free2
|
||||
long_name: Free 2
|
||||
---
|
||||
actioncost:
|
||||
- name: Varies
|
||||
abbr: varies
|
||||
|
@ -38,7 +37,6 @@ actioncost:
|
|||
abbr: free
|
||||
- name: Reaction
|
||||
abbr: reaction
|
||||
---
|
||||
alignment:
|
||||
- name: Lawful Good
|
||||
abbr: LG
|
||||
|
@ -58,7 +56,6 @@ alignment:
|
|||
abbr: NE
|
||||
- name: Chaotic Evil
|
||||
abbr: CE
|
||||
---
|
||||
frequency:
|
||||
- once per round
|
||||
- once per turn
|
||||
|
@ -66,19 +63,16 @@ frequency:
|
|||
- once every 10 minutes
|
||||
- once per hour
|
||||
- once per day
|
||||
---
|
||||
lang_rarity:
|
||||
- Common
|
||||
- Uncommon
|
||||
- Secret
|
||||
---
|
||||
movement:
|
||||
- Land
|
||||
- Burrow
|
||||
- Climb
|
||||
- Fly
|
||||
- Swim
|
||||
---
|
||||
size:
|
||||
- name: Tiny
|
||||
space_in_ft: 4
|
||||
|
@ -104,10 +98,9 @@ size:
|
|||
space_in_ft: 20
|
||||
reach_tall_ft: 20
|
||||
reach_long_Ft: 15
|
||||
---
|
||||
weapon_category:
|
||||
- Unarmed
|
||||
- Simple
|
||||
- Martial
|
||||
- Advanced
|
||||
---
|
||||
...
|
||||
|
|
Loading…
Reference in New Issue