fix: resolve database pathing issues in multi-environment setup
* Used absolute paths constructed from `app.root_path` (BASE_DIR)
* Modified `config.py` to ensure `sqlite:///{path}` works across Docker and Host Linux systems
This commit is contained in:
1 parent
8232f4d8f7
commit
1038b4ff05
1 file changed
+7
-4
@@ -38,6 +38,8 @@ import os
|
||||
from typing import Optional
|
||||
|
||||
|
||||
BASE_DIR = os.path.abspath(os.path.dirname(__file__))
|
||||
|
||||
class Config:
|
||||
"""
|
||||
Base configuration class with default values.
|
||||
@@ -60,10 +62,11 @@ class Config:
|
||||
DEV_USER_EMAIL: str = os.environ.get('DEV_USER_EMAIL', 'dev@formeleon.local')
|
||||
|
||||
# Database Configuration
|
||||
SQLALCHEMY_DATABASE_URI: str = os.environ.get(
|
||||
'SQLALCHEMY_DATABASE_URI',
|
||||
'sqlite:///formeleon.db'
|
||||
)
|
||||
if 'SQLALCHEMY_DATABASE_URI' in os.environ:
|
||||
SQLALCHEMY_DATABASE_URI: str = os.environ['SQLALCHEMY_DATABASE_URI']
|
||||
else:
|
||||
SQLALCHEMY_DATABASE_URI: str = f'sqlite:///{os.path.join(BASE_DIR, "instance", "formeleon.db")}'
|
||||
|
||||
SQLALCHEMY_TRACK_MODIFICATIONS: bool = False
|
||||
SQLALCHEMY_ECHO: bool = os.environ.get('SQLALCHEMY_ECHO', 'false').lower() == 'true'
|
||||
|
||||
|
||||
Reference in new issue
Block a user