From 2245baef3e1f7dda0d823ee2e80eaef798f54d34 Mon Sep 17 00:00:00 2001 From: Corder Guy Date: Tue, 17 Apr 2018 13:43:45 -0500 Subject: [PATCH] make database path portable --- mocha_server.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/mocha_server.py b/mocha_server.py index 536f204..bc7729d 100755 --- a/mocha_server.py +++ b/mocha_server.py @@ -4,11 +4,13 @@ Handle API requests to the database """ import json import sqlite3 +from os import path # NOTE: closing a database makes the next query in a script not work -# DATABASE = '/usr/local/www/mocha-server/mocha.db' -DATABASE = 'mocha.db' +DATABASE = '/usr/local/www/mocha-server/mocha.db' +if not path.exists(DATABASE): + DATABASE = 'mocha.db' conn = sqlite3.connect(DATABASE) conn.row_factory = sqlite3.Row