Skip to content

Commit

Permalink
Fix init-db call and circular dep.
Browse files Browse the repository at this point in the history
  • Loading branch information
scossu committed Sep 11, 2024
1 parent 7bee998 commit f0377ae
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
2 changes: 1 addition & 1 deletion entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ fi
host=${TXL_WEBAPP_HOST:-"0.0.0.0"}
port=${TXL_WEBAPP_PORT:-"8000"}

./sscli admin init--db
./sscli admin init-db

if [ "${FLASK_ENV}" == "development" ]; then
exec flask run -h $host -p $port
Expand Down
12 changes: 9 additions & 3 deletions scriptshifter/tables/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -151,8 +151,12 @@ def init_db():
"""
# Create parent diretories if necessary.
# If the DB already exists, it will be overwritten ONLY on success at
# thhis point.
makedirs(path.dirname(TMP_DB_PATH), exist_ok=True)
# hhis point.
if path.isfile(TMP_DB_PATH):
# Remove previous temp file (possibly from failed attempt)
unlink(TMP_DB_PATH)
else:
makedirs(path.dirname(TMP_DB_PATH), exist_ok=True)

conn = sqlite3.connect(TMP_DB_PATH)

Expand All @@ -162,9 +166,11 @@ def init_db():
conn.executescript(fh.read())

# Populate tables.
with open(path.join(TABLE_DIR, "index.yml")) as fh:
tlist = load(fh, Loader=Loader)
try:
with conn:
for tname, tdata in list_tables().items():
for tname, tdata in tlist.items():
res = conn.execute(
"""INSERT INTO tbl_language (
name, label, marc_code, description
Expand Down

0 comments on commit f0377ae

Please sign in to comment.