diff --git a/README.txt b/README.txt index 69a55dd..128573a 100644 --- a/README.txt +++ b/README.txt @@ -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 ======== . diff --git a/app.py b/app.py index 9e9f7b5..4caae25 100644 --- a/app.py +++ b/app.py @@ -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()) - seq_cur.execute( - "INSERT INTO reading_tracker VALUES('{}', {}, '{}')".format( - uid, start, last_used + 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)