MAJOR DIRECTORY OVERHAUL
parent
71ed03b165
commit
34ef5a6025
19
README.md
19
README.md
|
@ -28,6 +28,25 @@ will fit into memory easily so performance issues aren't likely to be a problem.
|
|||
Also, most use cases of this data will likely be read only, so the sqlite
|
||||
limitations on concurrent writes won't be an issue either.
|
||||
|
||||
## Stop yacking and tell me how to generate the database from the YAMl!
|
||||
|
||||
Ok!
|
||||
|
||||
You'll need a working python3 installation and the module `pyyaml` installed.
|
||||
|
||||
### To install pyyaml
|
||||
|
||||
Run the correct pip install command: `pip install pyyaml`. Depending on your
|
||||
operating system, this might be `pip3` or `python3-pip` instead of `pip`.
|
||||
|
||||
### Generate the database
|
||||
|
||||
From the repository root, navigate to the `bin` directory with a `cd ./bin` and
|
||||
then run `python3 gendb.py`. The code is not optimized for speed, so depending
|
||||
on your system and disk I/O, it might take a minute or so. The output file is
|
||||
currently a `tmp.db` in the repository root. You can then explore the db file
|
||||
with `sqlite3 tmp.db` called from the repository root directory.
|
||||
|
||||
## Where we need the most help right now
|
||||
|
||||
### Proofreading Spells.yaml
|
||||
|
|
|
@ -9,6 +9,9 @@ import os
|
|||
|
||||
def main():
|
||||
|
||||
# change directory to the data directory
|
||||
os.chdir('../data/')
|
||||
|
||||
# gets all files with a yaml extension in the directory
|
||||
yfiles = []
|
||||
for file in glob.glob("*.yaml"):
|
|
@ -1,30 +1,48 @@
|
|||
import sys
|
||||
# the append makes python look in the repo dir for other python modules
|
||||
sys.path.append('..')
|
||||
import yaml
|
||||
import sqlite3
|
||||
import os
|
||||
import pprint
|
||||
import sys
|
||||
from lib.basics import *
|
||||
import lib.utils as utils
|
||||
from lib.gendb.basics import *
|
||||
from lib.gendb import utils
|
||||
import pathlib
|
||||
|
||||
|
||||
DBFILE = 'tmp.db'
|
||||
DATA_PATH = "../data/yaml" # This is path relative to gendb.py
|
||||
DBOUTPUT_PATH = pathlib.Path().absolute().parent
|
||||
DATA_PATH = pathlib.Path().absolute().parent / 'data'
|
||||
|
||||
|
||||
def main():
|
||||
|
||||
print("DB output is in path: {}".format(DBOUTPUT_PATH))
|
||||
print("Data is in path: {}".format(DATA_PATH))
|
||||
|
||||
# CHANGE TO DIR WHERE DB FILE IS OUTPUT
|
||||
try:
|
||||
os.chdir(DBOUTPUT_PATH)
|
||||
except OSError as e:
|
||||
print("{}".format(e))
|
||||
|
||||
# delete DBfile and run fresh
|
||||
try:
|
||||
os.remove(DBFILE)
|
||||
except OSError as e:
|
||||
print("{}".format(e))
|
||||
print("No prior database file found to remove. Will create a new one. Error message: {}".format(e))
|
||||
|
||||
# Get a DB conn
|
||||
try:
|
||||
os.chdir(DBOUTPUT_PATH)
|
||||
except OSError as e:
|
||||
print("{}".format(e))
|
||||
conn = utils.get_db_conn(DBFILE)
|
||||
pragma = "PRAGMA foreign_keys = ON;"
|
||||
c = conn.cursor()
|
||||
c.execute(pragma)
|
||||
|
||||
# change directory to where the data currently is relative to script
|
||||
# CHANGE DIRECTORY TO WHERE THE DATA CURRENTLY IS RELATIVE TO SCRIPT
|
||||
try:
|
||||
os.chdir(DATA_PATH)
|
||||
except OSError as e:
|
|
@ -1,5 +1,6 @@
|
|||
import yaml
|
||||
import pprint
|
||||
import os
|
||||
|
||||
|
||||
def main():
|
||||
|
@ -8,6 +9,7 @@ def main():
|
|||
|
||||
|
||||
def standardize_monsters():
|
||||
os.chdir('../data/')
|
||||
with open('monsters.yaml', 'r') as f:
|
||||
data = yaml.full_load(f)
|
||||
goodset = set()
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue