moving database files
This commit is contained in:
19
db/db.py
19
db/db.py
@@ -4,7 +4,16 @@ import threading
|
||||
from tinydb import TinyDB
|
||||
|
||||
DB_ENV = os.environ.get('DB_ENV', 'prod')
|
||||
base_dir = os.path.dirname(__file__)
|
||||
|
||||
|
||||
project_root = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
|
||||
|
||||
if DB_ENV == 'prod':
|
||||
base_dir = os.path.join(project_root, 'data/db')
|
||||
else:
|
||||
base_dir = os.path.join(project_root, 'test_data/db')
|
||||
|
||||
os.makedirs(base_dir, exist_ok=True)
|
||||
|
||||
|
||||
class LockedTable:
|
||||
@@ -66,14 +75,6 @@ class LockedTable:
|
||||
|
||||
# Setup DB files next to this module
|
||||
|
||||
if DB_ENV == 'test':
|
||||
child_path = os.path.join(base_dir, 'test_children.json')
|
||||
task_path = os.path.join(base_dir, 'test_tasks.json')
|
||||
reward_path = os.path.join(base_dir, 'test_rewards.json')
|
||||
image_path = os.path.join(base_dir, 'test_images.json')
|
||||
pending_reward_path = os.path.join(base_dir, 'test_pending_rewards.json')
|
||||
|
||||
else:
|
||||
child_path = os.path.join(base_dir, 'children.json')
|
||||
task_path = os.path.join(base_dir, 'tasks.json')
|
||||
reward_path = os.path.join(base_dir, 'rewards.json')
|
||||
|
||||
Reference in New Issue
Block a user