bugfix: installation permissions error for sqlite writing

This commit is contained in:
2023-01-22 00:27:06 -08:00
parent cbd3ec8200
commit b95199aa73
2 changed files with 11 additions and 4 deletions
+4
View File
@@ -28,6 +28,10 @@ or by executing kjv-api-test.sh which will listen on 0.0.0.0:1612
Visiting the base directory will show the user-facing documentation via web browser or cURL.
When testing or doing a deployment, the data directory must be owned by whatever user is
running the program in order to prevent a sqlite3.OperationalError for writing to a "readonly"
database.
CONTENTS
========
.
+3
View File
@@ -520,11 +520,14 @@ def sequential_read(start=0, num=1, uid=None, getuid=False):
start = verse_ids.index(int(show(kw=start, get_start_verse_id=True)))
uid = str(uuid.uuid4())
try:
seq_cur.execute(
"INSERT INTO reading_tracker VALUES('{}', {}, '{}')".format(
uid, start, last_used
)
)
except sqlite3.OperationalError:
return jsonify({"error":"Something went wrong with the database. Check permissions?"})
seq_conn.commit()
dbg2("Created new UID: {}".format(uid))
return "Your new UID is: {}".format(uid)